Cosmic Ray Report

Date time: 18/10/2025 12:25:55

Total jobs: 2537

Complete: 2537 (100.00%)

Surviving mutants: 1394 (54.95%)

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent + "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.63s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" + "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.65s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent + "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.55s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent + "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T003404942872Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T003405819029Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ecd0c5a5cfc2e4e74: unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 20.36s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" + "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ecd52b76e9ba186f9: unsupported operand type(s) for +: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root + "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5a510a3e7a2a80ec: unsupported operand type(s) for +: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir + dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef1ffaf14dd148e56: unsupported operand type(s) for +: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent - "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.59s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" - "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.70s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent - "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.54s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent - "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e88680579a11ed179: unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" - "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e544aa32e3d522702: unsupported operand type(s) for -: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root - "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614edd165c4384e10926: unsupported operand type(s) for -: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir - dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8f05b55853cfafec: unsupported operand type(s) for -: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent * "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.59s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" * "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.72s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent * "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.58s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent * "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T130530131446Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T130531022096Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e792f6e3055462b45: can't multiply sequence by non-int of type 'WindowsPath'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" * "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee01ad4215e7bb69b: can't multiply sequence by non-int of type 'WindowsPath'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.52s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root * "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e288bfe8cd445933c: can't multiply sequence by non-int of type 'WindowsPath'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir * dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec6871a83d1f0fd71: can't multiply sequence by non-int of type 'WindowsPath'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent // "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.60s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" // "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.42s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent // "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.72s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent // "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ea1d69af5fc7401a4: unsupported operand type(s) for //: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" // "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4a45087bf92ffdb7: unsupported operand type(s) for //: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root // "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T112023995777Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T112024872348Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e134522e11cb1c446: unsupported operand type(s) for //: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 20.45s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir // dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4a729991f8f7f8a6: unsupported operand type(s) for //: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.20s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent % "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.66s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" % "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.57s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent % "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.56s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent % "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5057d7ab6a0fce85: unsupported operand type(s) for %: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.21s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" % "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e9ff01e656e7e0cf4: unsupported operand type(s) for %: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root % "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e3e43afe50fefc611: unsupported operand type(s) for %: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.38s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir % dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614edc9cc6da63827304: unsupported operand type(s) for %: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.16s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent ** "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.45s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" ** "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.69s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent ** "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.66s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent ** "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e8d43c1366a0ba6a8: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" ** "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e852b2b1da3aa6216: unsupported operand type(s) for ** or pow(): 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root ** "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T182829930995Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T182830813819Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e2f8fcb3745542c5a: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir ** dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6c562bb4965f9ad6: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.28s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent >> "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.59s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" >> "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
.FFFFFFF.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T000304241834Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T000304412243Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

13 failed, 29 passed, 9 warnings in 15.17s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent >> "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.59s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent >> "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0cddb52140f31a2e: unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" >> "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec62443ae862ff211: unsupported operand type(s) for >>: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root >> "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ebd2407068c603cd6: unsupported operand type(s) for >>: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.30s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir >> dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T121715372470Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T121716255387Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent << "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.62s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" << "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.55s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent << "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.67s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent << "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb17ce4072a243e0d: unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.43s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" << "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee9f7713b0bc4a5ca: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root << "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ea560270e32d1cfb1: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir << dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e91c7c170ec78fda1: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent | "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.65s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" | "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.47s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent | "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.78s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent | "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb9739a24d73ab147: unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.55s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" | "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee5cac79ee1e9b01b: unsupported operand type(s) for |: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root | "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0a542a326e0fe0d6: unsupported operand type(s) for |: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir | dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.FFFFF.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T220156171662Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T220157096191Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e332fb07f13bb1d06: unsupported operand type(s) for |: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

11 failed, 31 passed, 23 warnings in 20.49s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent & "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.70s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" & "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.55s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent & "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.58s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent & "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4b2ee2dd62b9bc5f: unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.31s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" & "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e18f97bcd5da6fb3e: unsupported operand type(s) for &: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root & "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e832040cf84fcd8d8: unsupported operand type(s) for &: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir & dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e203ed12e67037b80: unsupported operand type(s) for &: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent ^ "public-keys" / "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for /: 'str' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.69s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -45,7 +45,7 @@
     def _initialize_rmap(self) -> SimpleRMAP:
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
-        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
+        public_keys_dir = str(Path(__file__).parent.parent / "public-keys" ^ "pki")
         server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         return SimpleRMAP(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.53s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -46,7 +46,7 @@
         """Initialize the RMAP instance with proper key paths."""
         # Set up paths for keys
         public_keys_dir = str(Path(__file__).parent.parent / "public-keys" / "pki")
-        server_private_key = str(Path(__file__).parent / "server_priv.asc")
+        server_private_key = str(Path(__file__).parent ^ "server_priv.asc")
 
         return SimpleRMAP(
             self.storage_dir,
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.80s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent ^ "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec8e1bf5dcffc73f4: unsupported operand type(s) for /: 'str' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -160,7 +160,7 @@
             # Resolve file path
             storage_root = Path(self.storage_dir).resolve()
             # Always use static/Group_13.pdf for watermarking
-            file_path = Path(__file__).parent / "static" / "Group_13.pdf"
+            file_path = Path(__file__).parent / "static" ^ "Group_13.pdf"
             file_path = file_path.resolve()
 
             if not file_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef3c03c3194bf5751: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -270,7 +270,7 @@
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
-            rmap_dir = storage_root / "rmap_watermarks"
+            rmap_dir = storage_root ^ "rmap_watermarks"
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e9790a3df63dc940f: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -274,7 +274,7 @@
             rmap_dir.mkdir(parents=True, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
-            dest_path = rmap_dir / dest_filename
+            dest_path = rmap_dir ^ dest_filename
 
             # Write watermarked PDF
             with dest_path.open("wb") as f:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed52633584c26f0c9: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any + None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 16.16s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes + bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee8a25cf46791eaf9: unsupported operand type(s) for +: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any - None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.64s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes - bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e42932b3bccd79f37: unsupported operand type(s) for -: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any * None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 16.07s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes * bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee7cdad9480df0014: unsupported operand type(s) for *: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.24s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any / None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.47s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes / bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ea45f3511f69fade0: unsupported operand type(s) for /: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any // None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 16.02s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes // bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec0819e7d5bfedecc: unsupported operand type(s) for //: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any % None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.48s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes % bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e0107597a4a806524: unsupported operand type(s) for %: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any ** None:
         """
         Create a watermarked PDF for the RMAP session.
 
.FFF.F.F.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T131520362257Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T131520681095Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

11 failed, 31 passed, 9 warnings in 15.06s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes ** bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e735b064b0219877f: unsupported operand type(s) for ** or pow(): 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any >> None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.68s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes >> bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec481906fe55e9e57: unsupported operand type(s) for >>: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any << None:
         """
         Create a watermarked PDF for the RMAP session.
 
.FFFFFFF.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125717511912Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125717732013Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

13 failed, 29 passed, 9 warnings in 14.84s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes << bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.FFFFF.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150527019035Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150527931419Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed1e93184f72f4aea: unsupported operand type(s) for <<: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

11 failed, 31 passed, 23 warnings in 20.50s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any & None:
         """
         Create a watermarked PDF for the RMAP session.
 
.FFF.F.F.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T190840942718Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T190841278028Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

11 failed, 31 passed, 9 warnings in 14.91s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes & bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ea663648c72fffe81: unsupported operand type(s) for &: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.33s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -109,7 +109,7 @@
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
-    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
+    def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any ^ None:
         """
         Create a watermarked PDF for the RMAP session.
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.60s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes ^ bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb3e2c3addb6436c4: unsupported operand type(s) for ^: 'type' and 'type'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.98s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) != 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.94s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for != "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123846082818Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123846955293Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.58s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) < 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for < "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) <= 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for <= "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) > 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.19s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for > "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) >= 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.02s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for >= "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for is "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



rmap_handler.py:290

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\rmap_handler.py:290: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if intended_for is None or intended_for is "Unknown_Group":



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 21.18s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None or intended_for is not "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



rmap_handler.py:290

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\rmap_handler.py:290: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    if intended_for is None or intended_for is not "Unknown_Group":



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 20.75s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is not None or intended_for == "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.62s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -301,7 +301,7 @@
                         ),
                         {"path": str(file_path)},
                     ).first()
-                    if file_record is None:
+                    if file_record is not None:
                         return jsonify({"error": "File record not found"}), 500
                     did = file_record.id
 
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.42s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -101,7 +101,7 @@
 
                 # Try to create watermarked PDF
                 pdf_result = self._create_watermarked_pdf_for_session(session_secret)
-                if pdf_result is not None:
+                if pdf_result is None:
                     return pdf_result  # Return error response if PDF creation failed
 
             return jsonify(result), 200
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

>       response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:584: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:920: in full_dispatch_request

    return self.finalize_request(rv)

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:939: in finalize_request

    response = self.make_response(rv)

               ^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <Flask 'server'>, rv = None



    def make_response(self, rv: ft.ResponseReturnValue) -> Response:

        """Convert the return value from a view function to an instance of

        :attr:`response_class`.

    

        :param rv: the return value from the view function. The view function

            must return a response. Returning ``None``, or the view ending

            without returning, is not allowed. The following types are allowed

            for ``view_rv``:

    

            ``str``

                A response object is created with the string encoded to UTF-8

                as the body.

    

            ``bytes``

                A response object is created with the bytes as the body.

    

            ``dict``

                A dictionary that will be jsonify'd before being returned.

    

            ``list``

                A list that will be jsonify'd before being returned.

    

            ``generator`` or ``iterator``

                A generator that returns ``str`` or ``bytes`` to be

                streamed as the response.

    

            ``tuple``

                Either ``(body, status, headers)``, ``(body, status)``, or

                ``(body, headers)``, where ``body`` is any of the other types

                allowed here, ``status`` is a string or an integer, and

                ``headers`` is a dictionary or a list of ``(key, value)``

                tuples. If ``body`` is a :attr:`response_class` instance,

                ``status`` overwrites the exiting value and ``headers`` are

                extended.

    

            :attr:`response_class`

                The object is returned unchanged.

    

            other :class:`~werkzeug.wrappers.Response` class

                The object is coerced to :attr:`response_class`.

    

            :func:`callable`

                The function is called as a WSGI application. The result is

                used to create a response object.

    

        .. versionchanged:: 2.2

            A generator will be converted to a streaming response.

            A list will be converted to a JSON response.

    

        .. versionchanged:: 1.1

            A dict will be converted to a JSON response.

    

        .. versionchanged:: 0.9

           Previously a tuple was interpreted as the arguments for the

           response object.

        """

    

        status: int | None = None

        headers: HeadersValue | None = None

    

        # unpack tuple returns

        if isinstance(rv, tuple):

            len_rv = len(rv)

    

            # a 3-tuple is unpacked directly

            if len_rv == 3:

                rv, status, headers = rv  # type: ignore[misc]

            # decide if a 2-tuple has status or headers

            elif len_rv == 2:

                if isinstance(rv[1], (Headers, dict, tuple, list)):

                    rv, headers = rv  # pyright: ignore

                else:

                    rv, status = rv  # type: ignore[assignment,misc]

            # other sized tuples are not allowed

            else:

                raise TypeError(

                    "The view function did not return a valid response tuple."

                    " The tuple must have the form (body, status, headers),"

                    " (body, status), or (body, headers)."

                )

    

        # the body must not be None

        if rv is None:

>           raise TypeError(

                f"The view function for {request.endpoint!r} did not"

                " return a valid response. The function either returned"

                " None or ended without a return statement."

            )

E           TypeError: The view function for 'rmap_get_link' did not return a valid response. The function either returned None or ended without a return statement.



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1212: TypeError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - TypeError: The view function...

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.30s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -163,7 +163,7 @@
             file_path = Path(__file__).parent / "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
-            if not file_path.exists():
+            if  file_path.exists():
                 self.app.logger.error(f"Source PDF not found: {file_path}")
                 return jsonify({"error": "Source PDF not found"}), 500
 
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:167 Source PDF not found: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\static\Group_13.pdf

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.11s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -179,7 +179,7 @@
                         {"path": str(file_path)},
                     ).first()
 
-                    if not existing_file:
+                    if  existing_file:
                         # Need to insert a full Documents row following schema:
                         # (name, path, ownerid, sha256, size)
                         # We don't have an authenticated user in RMAP flow, so we
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.06s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -188,7 +188,7 @@
                         owner_row = conn.execute(
                             text("SELECT id FROM Users WHERE email = 'service@rmap.su'")
                         ).first()
-                        if not owner_row:
+                        if  owner_row:
                             raise RuntimeError(
                                 "No users exist to own RMAP base document; "
                                 "create a user first"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.28s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -237,7 +237,7 @@
                                     ),
                                     {"path": str(file_path)},
                                 ).first()
-                                if not existing_file:
+                                if  existing_file:
                                     raise race_e
                             except Exception:
                                 raise
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -254,7 +254,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=None
             )
-            if not applicable:
+            if  applicable:
                 return jsonify({"error": "Watermarking not applicable to PDF"}), 500
 
             # Apply watermark
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.09s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if  isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.21s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -76,7 +76,7 @@
             payload = request.get_json(silent=True) or {}
             result = self.rmap_instance.handle_message1(payload)
 
-            if "error" in result:
+            if not "error" in result:
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
             return jsonify(result), 200
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 23 warnings in 19.12s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if not "required" in result["error"] else 503
 
             return jsonify(result), 200
 
............F.............................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

>       assert response.status_code == 400

E       assert 503 == 400

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:543: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 400

1 failed, 41 passed, 23 warnings in 21.14s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -92,7 +92,7 @@
             payload = request.get_json(silent=True) or {}
             result = self.rmap_instance.handle_message2(payload)
 
-            if "error" in result:
+            if not "error" in result:
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.47s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if not "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.............F............................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614ef2f29c1820524fb1'}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

        shared_link["version_link"] = json_data.get("result")

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

>       assert response.status_code == 400

E       assert 503 == 400

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:596: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 400

1 failed, 41 passed, 23 warnings in 20.93s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -96,7 +96,7 @@
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
-            if "result" in result:
+            if not "result" in result:
                 session_secret = result["result"]
 
                 # Try to create watermarked PDF
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e5f1e0cadf9bcf71f'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:719 Version not found for link: 0000000000bc614e5f1e0cadf9bcf71f

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 20.87s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -101,7 +101,7 @@
 
                 # Try to create watermarked PDF
                 pdf_result = self._create_watermarked_pdf_for_session(session_secret)
-                if pdf_result is not None:
+                if not pdf_result is not None:
                     return pdf_result  # Return error response if PDF creation failed
 
             return jsonify(result), 200
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

>       response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:584: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:920: in full_dispatch_request

    return self.finalize_request(rv)

           ^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:939: in finalize_request

    response = self.make_response(rv)

               ^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <Flask 'server'>, rv = None



    def make_response(self, rv: ft.ResponseReturnValue) -> Response:

        """Convert the return value from a view function to an instance of

        :attr:`response_class`.

    

        :param rv: the return value from the view function. The view function

            must return a response. Returning ``None``, or the view ending

            without returning, is not allowed. The following types are allowed

            for ``view_rv``:

    

            ``str``

                A response object is created with the string encoded to UTF-8

                as the body.

    

            ``bytes``

                A response object is created with the bytes as the body.

    

            ``dict``

                A dictionary that will be jsonify'd before being returned.

    

            ``list``

                A list that will be jsonify'd before being returned.

    

            ``generator`` or ``iterator``

                A generator that returns ``str`` or ``bytes`` to be

                streamed as the response.

    

            ``tuple``

                Either ``(body, status, headers)``, ``(body, status)``, or

                ``(body, headers)``, where ``body`` is any of the other types

                allowed here, ``status`` is a string or an integer, and

                ``headers`` is a dictionary or a list of ``(key, value)``

                tuples. If ``body`` is a :attr:`response_class` instance,

                ``status`` overwrites the exiting value and ``headers`` are

                extended.

    

            :attr:`response_class`

                The object is returned unchanged.

    

            other :class:`~werkzeug.wrappers.Response` class

                The object is coerced to :attr:`response_class`.

    

            :func:`callable`

                The function is called as a WSGI application. The result is

                used to create a response object.

    

        .. versionchanged:: 2.2

            A generator will be converted to a streaming response.

            A list will be converted to a JSON response.

    

        .. versionchanged:: 1.1

            A dict will be converted to a JSON response.

    

        .. versionchanged:: 0.9

           Previously a tuple was interpreted as the arguments for the

           response object.

        """

    

        status: int | None = None

        headers: HeadersValue | None = None

    

        # unpack tuple returns

        if isinstance(rv, tuple):

            len_rv = len(rv)

    

            # a 3-tuple is unpacked directly

            if len_rv == 3:

                rv, status, headers = rv  # type: ignore[misc]

            # decide if a 2-tuple has status or headers

            elif len_rv == 2:

                if isinstance(rv[1], (Headers, dict, tuple, list)):

                    rv, headers = rv  # pyright: ignore

                else:

                    rv, status = rv  # type: ignore[assignment,misc]

            # other sized tuples are not allowed

            else:

                raise TypeError(

                    "The view function did not return a valid response tuple."

                    " The tuple must have the form (body, status, headers),"

                    " (body, status), or (body, headers)."

                )

    

        # the body must not be None

        if rv is None:

>           raise TypeError(

                f"The view function for {request.endpoint!r} did not"

                " return a valid response. The function either returned"

                " None or ended without a return statement."

            )

E           TypeError: The view function for 'rmap_get_link' did not return a valid response. The function either returned None or ended without a return statement.



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1212: TypeError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - TypeError: The view function...

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.15s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -132,7 +132,7 @@
                     {"link": session_secret},
                 ).first()
 
-                if existing_version:
+                if not existing_version:
                     # Check if the file actually exists on disk
                     existing_path = Path(existing_version.path)
                     if existing_path.exists():
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.86s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -135,7 +135,7 @@
                 if existing_version:
                     # Check if the file actually exists on disk
                     existing_path = Path(existing_version.path)
-                    if existing_path.exists():
+                    if not existing_path.exists():
                         self.app.logger.info(
                             f"RMAP watermarked PDF already exists: {session_secret}"
                         )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -163,7 +163,7 @@
             file_path = Path(__file__).parent / "static" / "Group_13.pdf"
             file_path = file_path.resolve()
 
-            if not file_path.exists():
+            if not not file_path.exists():
                 self.app.logger.error(f"Source PDF not found: {file_path}")
                 return jsonify({"error": "Source PDF not found"}), 500
 
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:167 Source PDF not found: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\static\Group_13.pdf

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.89s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -179,7 +179,7 @@
                         {"path": str(file_path)},
                     ).first()
 
-                    if not existing_file:
+                    if not not existing_file:
                         # Need to insert a full Documents row following schema:
                         # (name, path, ownerid, sha256, size)
                         # We don't have an authenticated user in RMAP flow, so we
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.14s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -188,7 +188,7 @@
                         owner_row = conn.execute(
                             text("SELECT id FROM Users WHERE email = 'service@rmap.su'")
                         ).first()
-                        if not owner_row:
+                        if not not owner_row:
                             raise RuntimeError(
                                 "No users exist to own RMAP base document; "
                                 "create a user first"
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.12s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -237,7 +237,7 @@
                                     ),
                                     {"path": str(file_path)},
                                 ).first()
-                                if not existing_file:
+                                if not not existing_file:
                                     raise race_e
                             except Exception:
                                 raise
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.60s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -254,7 +254,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=None
             )
-            if not applicable:
+            if not not applicable:
                 return jsonify({"error": "Watermarking not applicable to PDF"}), 500
 
             # Apply watermark
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.26s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.12s

operator: core/AddNot, occurrence: 14
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if not intended_for is None or intended_for == "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123929166249Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123930042528Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.37s

operator: core/AddNot, occurrence: 15
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -301,7 +301,7 @@
                         ),
                         {"path": str(file_path)},
                     ).first()
-                    if file_record is None:
+                    if not file_record is None:
                         return jsonify({"error": "File record not found"}), 500
                     did = file_record.id
 
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.05s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -73,7 +73,7 @@
     def handle_rmap_initiate(self):
         """Handle RMAP message 1 (initiate authentication)."""
         try:
-            payload = request.get_json(silent=True) or {}
+            payload = request.get_json(silent=False) or {}
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
............F.............................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

>       assert response.status_code == 400

E       assert 503 == 400

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:543: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 400

1 failed, 41 passed, 23 warnings in 20.97s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -89,7 +89,7 @@
     def handle_rmap_get_link(self):
         """Handle RMAP message 2 (get session link)."""
         try:
-            payload = request.get_json(silent=True) or {}
+            payload = request.get_json(silent=False) or {}
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
.FFFFFFF.FFF.F............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124600612863Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124601535906Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614ebb7e80f797844cfa'}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

        shared_link["version_link"] = json_data.get("result")

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

>       assert response.status_code == 400

E       assert 503 == 400

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:596: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 400

11 failed, 31 passed, 23 warnings in 20.81s

operator: core/ReplaceTrueWithFalse, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -271,7 +271,7 @@
 
             # Create destination directory and file
             rmap_dir = storage_root / "rmap_watermarks"
-            rmap_dir.mkdir(parents=True, exist_ok=True)
+            rmap_dir.mkdir(parents=False, exist_ok=True)
 
             dest_filename = f"rmap_{session_secret}.pdf"
             dest_path = rmap_dir / dest_filename
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.42s

operator: core/ReplaceTrueWithFalse, occurrence: 3
Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 46, in run_tests
    proc = subprocess.run(shlex.split(command), check=True, env=env, timeout=timeout, capture_output=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pytest', '../test/test_api.py', '../test/test_watermarking_all_methods.py', '../test/test_watermarking_utilities.py']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\mutating.py", line 75, in mutate_and_test
    test_outcome, output = run_tests(test_command, timeout)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 51, in run_tests
    return (TestOutcome.KILLED, err.output.decode("utf-8"))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 2260: invalid continuation byte
operator: core/ReplaceTrueWithFalse, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -334,7 +334,7 @@
             except Exception as db_e:
                 # If database insert fails, clean up the file
                 try:
-                    dest_path.unlink(missing_ok=True)
+                    dest_path.unlink(missing_ok=False)
                 except Exception as cleanup_e:
                     self.app.logger.error(
                         f"Failed to cleanup file after DB error: {cleanup_e}"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -73,7 +73,7 @@
     def handle_rmap_initiate(self):
         """Handle RMAP message 1 (initiate authentication)."""
         try:
-            payload = request.get_json(silent=True) or {}
+            payload = request.get_json(silent=True) and {}
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 400 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 400 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 23 warnings in 16.77s

operator: core/ReplaceOrWithAnd, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -89,7 +89,7 @@
     def handle_rmap_get_link(self):
         """Handle RMAP message 2 (get session link)."""
         try:
-            payload = request.get_json(silent=True) or {}
+            payload = request.get_json(silent=True) and {}
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 400 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.64s

operator: core/ReplaceOrWithAnd, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) and len(wm_bytes) == 0:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ReplaceOrWithAnd, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -287,7 +287,7 @@
                     intended_for = self.rmap_instance.get_session_identity(
                         session_secret
                     )
-                    if intended_for is None or intended_for == "Unknown_Group":
+                    if intended_for is None and intended_for == "Unknown_Group":
                         # Use a more descriptive fallback that
                         # indicates RMAP authentication
                         intended_for = "RMAP_CLIENT"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -81,7 +81,7 @@
 
             return jsonify(result), 200
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return jsonify(
                 {"error": f"RMAP system initialization failed: {str(e)}"}
             ), 503
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.32s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -106,7 +106,7 @@
 
             return jsonify(result), 200
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
 
     def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T213027660111Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T213028481349Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.53s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -152,7 +152,7 @@
                             f" {session_secret}"
                         )
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return jsonify({"error": f"Database error: {str(e)}"}), 500
 
         # Create watermarked PDF
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.33s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -198,7 +198,7 @@
                         # Gather file metadata
                         try:
                             pdf_bytes = file_path.read_bytes()
-                        except Exception as fe:
+                        except CosmicRayTestingException as fe:
                             raise RuntimeError(
                                 f"Failed reading source PDF for RMAP insertion: {fe}"
                             ) from fe
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -226,7 +226,7 @@
                                     "size": int(size),
                                 },
                             )
-                        except Exception as race_e:
+                        except CosmicRayTestingException as race_e:
                             # If due to unique path constraint, fetch existing id;
                             # otherwise re-raise
                             try:
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123400274037Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123401190151Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.94s

operator: core/ExceptionReplacer, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -239,7 +239,7 @@
                                 ).first()
                                 if not existing_file:
                                     raise race_e
-                            except Exception:
+                            except CosmicRayTestingException:
                                 raise
             except Exception as db_e:
                 self.app.logger.error(f"Failed to add source PDF to database: {db_e}")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ExceptionReplacer, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -241,7 +241,7 @@
                                     raise race_e
                             except Exception:
                                 raise
-            except Exception as db_e:
+            except CosmicRayTestingException as db_e:
                 self.app.logger.error(f"Failed to add source PDF to database: {db_e}")
                 return jsonify({"error": f"Database error: {str(db_e)}"}), 500
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ExceptionReplacer, occurrence: 7
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -331,7 +331,7 @@
                 )
                 return None  # Success
 
-            except Exception as db_e:
+            except CosmicRayTestingException as db_e:
                 # If database insert fails, clean up the file
                 try:
                     dest_path.unlink(missing_ok=True)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ExceptionReplacer, occurrence: 8
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -335,7 +335,7 @@
                 # If database insert fails, clean up the file
                 try:
                     dest_path.unlink(missing_ok=True)
-                except Exception as cleanup_e:
+                except CosmicRayTestingException as cleanup_e:
                     self.app.logger.error(
                         f"Failed to cleanup file after DB error: {cleanup_e}"
                     )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ExceptionReplacer, occurrence: 9
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -348,7 +348,7 @@
                     {"error": f"Database insertion failed: {str(db_e)}"}
                 ), 500
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             self.app.logger.error(
                 f"Failed to create watermarked PDF for session"
                 f" {session_secret}: {str(e)}"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 401 if "required" in result["error"] else 503
 
             return jsonify(result), 200
 
............F.............................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

>       assert response.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:543: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.03s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 399 if "required" in result["error"] else 503
 
             return jsonify(result), 200
 
............F.............................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

>       assert response.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:543: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 399 == 400

1 failed, 41 passed, 23 warnings in 21.22s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if "required" in result["error"] else 504
 
             return jsonify(result), 200
 
.FFF.F.F.FFFF.............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T175720966335Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T175721852137Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

        assert response.status_code == 400

    

        # Wrong format params

        response = client.post("/api/rmap-initiate", json={"payload":"wrongformatstring"})

>       assert response.status_code == 503

E       assert 504 == 503

E        +  where 504 = <WrapperTestResponse streamed [504 GATEWAY TIMEOUT]>.status_code



..\test\test_api.py:547: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 504 == 503

9 failed, 33 passed, 23 warnings in 20.59s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -77,7 +77,7 @@
             result = self.rmap_instance.handle_message1(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if "required" in result["error"] else 502
 
             return jsonify(result), 200
 
............F.............................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt and inspect response payload

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        assert decrypted["nonceClient"] == test_nonce

        assert isinstance(decrypted["nonceServer"], int)

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-initiate")

        assert response.status_code == 400

    

        # Wrong format params

        response = client.post("/api/rmap-initiate", json={"payload":"wrongformatstring"})

>       assert response.status_code == 503

E       assert 502 == 503

E        +  where 502 = <WrapperTestResponse streamed [502 BAD GATEWAY]>.status_code



..\test\test_api.py:547: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 502 == 503

1 failed, 41 passed, 23 warnings in 21.03s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -79,7 +79,7 @@
             if "error" in result:
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
-            return jsonify(result), 200
+            return jsonify(result), 201
 
         except Exception as e:
             return jsonify(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 201 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 201 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 23 warnings in 19.03s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -79,7 +79,7 @@
             if "error" in result:
                 return jsonify(result), 400 if "required" in result["error"] else 503
 
-            return jsonify(result), 200
+            return jsonify(result), 199
 
         except Exception as e:
             return jsonify(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 199 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 199 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 23 warnings in 19.00s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -84,7 +84,7 @@
         except Exception as e:
             return jsonify(
                 {"error": f"RMAP system initialization failed: {str(e)}"}
-            ), 503
+            ), 504
 
     def handle_rmap_get_link(self):
         """Handle RMAP message 2 (get session link)."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -84,7 +84,7 @@
         except Exception as e:
             return jsonify(
                 {"error": f"RMAP system initialization failed: {str(e)}"}
-            ), 503
+            ), 502
 
     def handle_rmap_get_link(self):
         """Handle RMAP message 2 (get session link)."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 401 if "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.............F............................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614ea08c440cd3a8ad91'}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

        shared_link["version_link"] = json_data.get("result")

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

>       assert response.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:596: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 399 if "required" in result["error"] else 503
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.............F............................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614ee888173d7b293c4f'}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

        shared_link["version_link"] = json_data.get("result")

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

>       assert response.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:596: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 399 == 400

1 failed, 41 passed, 23 warnings in 21.63s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if "required" in result["error"] else 504
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.FFFFFFF.FFF.F............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T145637758545Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T145638623807Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e93c52b3c874152a5'}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

        shared_link["version_link"] = json_data.get("result")

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

        assert response.status_code == 400

    

        # Wrong format params

        response = client.post("/api/rmap-get-link", json={"payload":"wrongformatstring"})

>       assert response.status_code == 503

E       assert 504 == 503

E        +  where 504 = <WrapperTestResponse streamed [504 GATEWAY TIMEOUT]>.status_code



..\test\test_api.py:600: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 504 == 503

11 failed, 31 passed, 23 warnings in 20.60s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -93,7 +93,7 @@
             result = self.rmap_instance.handle_message2(payload)
 
             if "error" in result:
-                return jsonify(result), 400 if "required" in result["error"] else 503
+                return jsonify(result), 400 if "required" in result["error"] else 502
 
             # If RMAP authentication succeeded, create watermarked PDF
             if "result" in result:
.............F............................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e3046e08b2e065203'}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

    

        assert "result" in json_data

        assert isinstance(json_data["result"], str)

        assert len(json_data["result"]) == 32

        shared_link["version_link"] = json_data.get("result")

    

        # Test with wrong parameters

        # Missing params

        response = client.post("/api/rmap-get-link")

        assert response.status_code == 400

    

        # Wrong format params

        response = client.post("/api/rmap-get-link", json={"payload":"wrongformatstring"})

>       assert response.status_code == 503

E       assert 502 == 503

E        +  where 502 = <WrapperTestResponse streamed [502 BAD GATEWAY]>.status_code



..\test\test_api.py:600: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 502 == 503

1 failed, 41 passed, 23 warnings in 21.69s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -104,7 +104,7 @@
                 if pdf_result is not None:
                     return pdf_result  # Return error response if PDF creation failed
 
-            return jsonify(result), 200
+            return jsonify(result), 201
 
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 201 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.39s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -104,7 +104,7 @@
                 if pdf_result is not None:
                     return pdf_result  # Return error response if PDF creation failed
 
-            return jsonify(result), 200
+            return jsonify(result), 199
 
         except Exception as e:
             return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 199 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 21.34s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -107,7 +107,7 @@
             return jsonify(result), 200
 
         except Exception as e:
-            return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
+            return jsonify({"error": f"RMAP system error: {str(e)}"}), 504
 
     def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
         """
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -107,7 +107,7 @@
             return jsonify(result), 200
 
         except Exception as e:
-            return jsonify({"error": f"RMAP system error: {str(e)}"}), 503
+            return jsonify({"error": f"RMAP system error: {str(e)}"}), 502
 
     def _create_watermarked_pdf_for_session(self, session_secret: str) -> Any | None:
         """
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -153,7 +153,7 @@
                         )
 
         except Exception as e:
-            return jsonify({"error": f"Database error: {str(e)}"}), 500
+            return jsonify({"error": f"Database error: {str(e)}"}), 501
 
         # Create watermarked PDF
         try:
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193012836974Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193013703704Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.36s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -153,7 +153,7 @@
                         )
 
         except Exception as e:
-            return jsonify({"error": f"Database error: {str(e)}"}), 500
+            return jsonify({"error": f"Database error: {str(e)}"}), 499
 
         # Create watermarked PDF
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -165,7 +165,7 @@
 
             if not file_path.exists():
                 self.app.logger.error(f"Source PDF not found: {file_path}")
-                return jsonify({"error": "Source PDF not found"}), 500
+                return jsonify({"error": "Source PDF not found"}), 501
 
             # Add file to database if not already present
             try:
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T204913267915Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T204914091439Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.64s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -165,7 +165,7 @@
 
             if not file_path.exists():
                 self.app.logger.error(f"Source PDF not found: {file_path}")
-                return jsonify({"error": "Source PDF not found"}), 500
+                return jsonify({"error": "Source PDF not found"}), 499
 
             # Add file to database if not already present
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -243,7 +243,7 @@
                                 raise
             except Exception as db_e:
                 self.app.logger.error(f"Failed to add source PDF to database: {db_e}")
-                return jsonify({"error": f"Database error: {str(db_e)}"}), 500
+                return jsonify({"error": f"Database error: {str(db_e)}"}), 501
 
             # Use robust-xmp watermarking (best technique)
             method = "robust-xmp"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.31s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -243,7 +243,7 @@
                                 raise
             except Exception as db_e:
                 self.app.logger.error(f"Failed to add source PDF to database: {db_e}")
-                return jsonify({"error": f"Database error: {str(db_e)}"}), 500
+                return jsonify({"error": f"Database error: {str(db_e)}"}), 499
 
             # Use robust-xmp watermarking (best technique)
             method = "robust-xmp"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -255,7 +255,7 @@
                 method=method, pdf=str(file_path), position=None
             )
             if not applicable:
-                return jsonify({"error": "Watermarking not applicable to PDF"}), 500
+                return jsonify({"error": "Watermarking not applicable to PDF"}), 501
 
             # Apply watermark
             wm_bytes = WMUtils.apply_watermark(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -255,7 +255,7 @@
                 method=method, pdf=str(file_path), position=None
             )
             if not applicable:
-                return jsonify({"error": "Watermarking not applicable to PDF"}), 500
+                return jsonify({"error": "Watermarking not applicable to PDF"}), 499
 
             # Apply watermark
             wm_bytes = WMUtils.apply_watermark(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 1:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -266,7 +266,7 @@
                 position=None,
             )
 
-            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == -1:
                 return jsonify({"error": "Watermarking produced no output"}), 500
 
             # Create destination directory and file
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -267,7 +267,7 @@
             )
 
             if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
-                return jsonify({"error": "Watermarking produced no output"}), 500
+                return jsonify({"error": "Watermarking produced no output"}), 501
 
             # Create destination directory and file
             rmap_dir = storage_root / "rmap_watermarks"
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194332681768Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194333535445Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.52s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -267,7 +267,7 @@
             )
 
             if not isinstance(wm_bytes, bytes | bytearray) or len(wm_bytes) == 0:
-                return jsonify({"error": "Watermarking produced no output"}), 500
+                return jsonify({"error": "Watermarking produced no output"}), 499
 
             # Create destination directory and file
             rmap_dir = storage_root / "rmap_watermarks"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -302,7 +302,7 @@
                         {"path": str(file_path)},
                     ).first()
                     if file_record is None:
-                        return jsonify({"error": "File record not found"}), 500
+                        return jsonify({"error": "File record not found"}), 501
                     did = file_record.id
 
                     conn.execute(
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T114753314025Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T114754201483Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.57s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -302,7 +302,7 @@
                         {"path": str(file_path)},
                     ).first()
                     if file_record is None:
-                        return jsonify({"error": "File record not found"}), 500
+                        return jsonify({"error": "File record not found"}), 499
                     did = file_record.id
 
                     conn.execute(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -346,7 +346,7 @@
                 )
                 return jsonify(
                     {"error": f"Database insertion failed: {str(db_e)}"}
-                ), 500
+                ), 501
 
         except Exception as e:
             self.app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -346,7 +346,7 @@
                 )
                 return jsonify(
                     {"error": f"Database insertion failed: {str(db_e)}"}
-                ), 500
+                ), 499
 
         except Exception as e:
             self.app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -355,5 +355,5 @@
             )
             return jsonify(
                 {"error": f"Failed to create watermarked PDF: {str(e)}"}
-            ), 500
-
+            ), 501
+
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- armap_handler.py
+++ brmap_handler.py
@@ -355,5 +355,5 @@
             )
             return jsonify(
                 {"error": f"Failed to create watermarked PDF: {str(e)}"}
-            ), 500
-
+            ), 499
+
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.29s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] + None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] - None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] * None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] / None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] // None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] % None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.32s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] ** None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T223727818207Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T223728673004Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.39s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] >> None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] << None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] & None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -226,7 +226,7 @@
 # --------------------
 
 
-def main(argv: Iterable[str] | None = None) -> int:
+def main(argv: Iterable[str] ^ None = None) -> int:
     parser = build_parser()
     args = parser.parse_args(list(argv) if argv is not None else None)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ != "__main__":
     raise SystemExit(main())
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ < "__main__":
     raise SystemExit(main())
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ <= "__main__":
     raise SystemExit(main())
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ > "__main__":
     raise SystemExit(main())
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ >= "__main__":
     raise SystemExit(main())
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ is "__main__":
     raise SystemExit(main())
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if __name__ is not "__main__":
     raise SystemExit(main())
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -63,7 +63,7 @@
 
 
 def _resolve_secret(args: argparse.Namespace) -> str:
-    if args.secret is not None:
+    if args.secret is None:
         return args.secret
     if args.secret_file is not None:
         return _read_text_from_file(args.secret_file)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T004623392209Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T004624304106Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.30s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -65,7 +65,7 @@
 def _resolve_secret(args: argparse.Namespace) -> str:
     if args.secret is not None:
         return args.secret
-    if args.secret_file is not None:
+    if args.secret_file is None:
         return _read_text_from_file(args.secret_file)
     if args.secret_stdin:
         return _read_text_from_stdin()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 2
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -74,7 +74,7 @@
 
 
 def _resolve_key(args: argparse.Namespace) -> str:
-    if args.key is not None:
+    if args.key is None:
         return args.key
     if args.key_file is not None:
         return _read_text_from_file(args.key_file).strip("\n\r")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 3
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -76,7 +76,7 @@
 def _resolve_key(args: argparse.Namespace) -> str:
     if args.key is not None:
         return args.key
-    if args.key_file is not None:
+    if args.key_file is None:
         return _read_text_from_file(args.key_file).strip("\n\r")
     if args.key_stdin:
         return _read_text_from_stdin().strip("\n\r")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 4
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -228,7 +228,7 @@
 
 def main(argv: Iterable[str] | None = None) -> int:
     parser = build_parser()
-    args = parser.parse_args(list(argv) if argv is not None else None)
+    args = parser.parse_args(list(argv) if argv is None else None)
 
     try:
         return int(args.func(args))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -57,7 +57,7 @@
 
 def _read_text_from_stdin() -> str:
     data = sys.stdin.read()
-    if not data:
+    if  data:
         raise ValueError("No data received on stdin")
     return data
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -111,7 +111,7 @@
 def cmd_embed(args: argparse.Namespace) -> int:
     key = _resolve_key(args)
     secret = _resolve_secret(args)
-    if not is_watermarking_applicable(
+    if  is_watermarking_applicable(
         method=args.method, pdf=args.input, position=args.position
     ):
         print(
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T172035768008Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T172036602839Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.57s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -57,7 +57,7 @@
 
 def _read_text_from_stdin() -> str:
     data = sys.stdin.read()
-    if not data:
+    if not not data:
         raise ValueError("No data received on stdin")
     return data
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.31s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -63,7 +63,7 @@
 
 
 def _resolve_secret(args: argparse.Namespace) -> str:
-    if args.secret is not None:
+    if not args.secret is not None:
         return args.secret
     if args.secret_file is not None:
         return _read_text_from_file(args.secret_file)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -65,7 +65,7 @@
 def _resolve_secret(args: argparse.Namespace) -> str:
     if args.secret is not None:
         return args.secret
-    if args.secret_file is not None:
+    if not args.secret_file is not None:
         return _read_text_from_file(args.secret_file)
     if args.secret_stdin:
         return _read_text_from_stdin()
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T231442190353Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T231443123611Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.59s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -67,7 +67,7 @@
         return args.secret
     if args.secret_file is not None:
         return _read_text_from_file(args.secret_file)
-    if args.secret_stdin:
+    if not args.secret_stdin:
         return _read_text_from_stdin()
     # Interactive fallback
     return getpass.getpass("Secret: ")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -74,7 +74,7 @@
 
 
 def _resolve_key(args: argparse.Namespace) -> str:
-    if args.key is not None:
+    if not args.key is not None:
         return args.key
     if args.key_file is not None:
         return _read_text_from_file(args.key_file).strip("\n\r")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -76,7 +76,7 @@
 def _resolve_key(args: argparse.Namespace) -> str:
     if args.key is not None:
         return args.key
-    if args.key_file is not None:
+    if not args.key_file is not None:
         return _read_text_from_file(args.key_file).strip("\n\r")
     if args.key_stdin:
         return _read_text_from_stdin().strip("\n\r")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -78,7 +78,7 @@
         return args.key
     if args.key_file is not None:
         return _read_text_from_file(args.key_file).strip("\n\r")
-    if args.key_stdin:
+    if not args.key_stdin:
         return _read_text_from_stdin().strip("\n\r")
     if args.key_prompt:
         return getpass.getpass("Key: ")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -80,7 +80,7 @@
         return _read_text_from_file(args.key_file).strip("\n\r")
     if args.key_stdin:
         return _read_text_from_stdin().strip("\n\r")
-    if args.key_prompt:
+    if not args.key_prompt:
         return getpass.getpass("Key: ")
     # If nothing provided, still prompt (safer default)
     return getpass.getpass("Key: ")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -99,7 +99,7 @@
 
 def cmd_explore(args: argparse.Namespace) -> int:
     tree = explore_pdf(args.input)
-    if args.out:
+    if not args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
             json.dump(tree, fh, indent=2, ensure_ascii=False)
     else:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -111,7 +111,7 @@
 def cmd_embed(args: argparse.Namespace) -> int:
     key = _resolve_key(args)
     secret = _resolve_secret(args)
-    if not is_watermarking_applicable(
+    if not not is_watermarking_applicable(
         method=args.method, pdf=args.input, position=args.position
     ):
         print(
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105832641787Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105833575990Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.69s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -137,7 +137,7 @@
 def cmd_extract(args: argparse.Namespace) -> int:
     key = _resolve_key(args)
     secret = read_watermark(method=args.method, pdf=args.input, key=key)
-    if args.out:
+    if not args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
             fh.write(secret)
         print(f"Wrote secret -> {args.out}")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -228,7 +228,7 @@
 
 def main(argv: Iterable[str] | None = None) -> int:
     parser = build_parser()
-    args = parser.parse_args(list(argv) if argv is not None else None)
+    args = parser.parse_args(list(argv) if not argv is not None else None)
 
     try:
         return int(args.func(args))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -249,6 +249,6 @@
         return 5
 
 
-if __name__ == "__main__":
+if not __name__ == "__main__":
     raise SystemExit(main())
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -157,7 +157,7 @@
     )
     p.add_argument("--version", action="version", version=f"pdfwm {__version__}")
 
-    sub = p.add_subparsers(dest="cmd", required=True)
+    sub = p.add_subparsers(dest="cmd", required=False)
 
     # methods
     p_methods = sub.add_parser("methods", help="List available watermarking methods")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -101,7 +101,7 @@
     tree = explore_pdf(args.input)
     if args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
-            json.dump(tree, fh, indent=2, ensure_ascii=False)
+            json.dump(tree, fh, indent=2, ensure_ascii=True)
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -103,7 +103,7 @@
         with open(args.out, "w", encoding="utf-8") as fh:
             json.dump(tree, fh, indent=2, ensure_ascii=False)
     else:
-        json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
+        json.dump(tree, sys.stdout, indent=2, ensure_ascii=True)
         print()
     return 0
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -232,7 +232,7 @@
 
     try:
         return int(args.func(args))
-    except FileNotFoundError as e:
+    except CosmicRayTestingException as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
     except ValueError as e:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144123770928Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144124641058Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.64s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -235,7 +235,7 @@
     except FileNotFoundError as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
-    except ValueError as e:
+    except CosmicRayTestingException as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
     except SecretNotFoundError as e:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -238,7 +238,7 @@
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
-    except SecretNotFoundError as e:
+    except CosmicRayTestingException as e:
         print(f"secret not found: {e}", file=sys.stderr)
         return 3
     except InvalidKeyError as e:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.38s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -241,7 +241,7 @@
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
         return 3
-    except InvalidKeyError as e:
+    except CosmicRayTestingException as e:
         print(f"invalid key: {e}", file=sys.stderr)
         return 4
     except WatermarkingError as e:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -244,7 +244,7 @@
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
         return 4
-    except WatermarkingError as e:
+    except CosmicRayTestingException as e:
         print(f"watermarking error: {e}", file=sys.stderr)
         return 5
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -94,7 +94,7 @@
 def cmd_methods(_args: argparse.Namespace) -> int:
     for name in sorted(METHODS):
         print(name)
-    return 0
+    return 1
 
 
 def cmd_explore(args: argparse.Namespace) -> int:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -94,7 +94,7 @@
 def cmd_methods(_args: argparse.Namespace) -> int:
     for name in sorted(METHODS):
         print(name)
-    return 0
+    return -1
 
 
 def cmd_explore(args: argparse.Namespace) -> int:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -101,7 +101,7 @@
     tree = explore_pdf(args.input)
     if args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
-            json.dump(tree, fh, indent=2, ensure_ascii=False)
+            json.dump(tree, fh, indent= 3, ensure_ascii=False)
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -101,7 +101,7 @@
     tree = explore_pdf(args.input)
     if args.out:
         with open(args.out, "w", encoding="utf-8") as fh:
-            json.dump(tree, fh, indent=2, ensure_ascii=False)
+            json.dump(tree, fh, indent= 1, ensure_ascii=False)
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.67s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -103,7 +103,7 @@
         with open(args.out, "w", encoding="utf-8") as fh:
             json.dump(tree, fh, indent=2, ensure_ascii=False)
     else:
-        json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
+        json.dump(tree, sys.stdout, indent= 3, ensure_ascii=False)
         print()
     return 0
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -103,7 +103,7 @@
         with open(args.out, "w", encoding="utf-8") as fh:
             json.dump(tree, fh, indent=2, ensure_ascii=False)
     else:
-        json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
+        json.dump(tree, sys.stdout, indent= 1, ensure_ascii=False)
         print()
     return 0
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -105,7 +105,7 @@
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
-    return 0
+    return 1
 
 
 def cmd_embed(args: argparse.Namespace) -> int:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.27s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -105,7 +105,7 @@
     else:
         json.dump(tree, sys.stdout, indent=2, ensure_ascii=False)
         print()
-    return 0
+    return -1
 
 
 def cmd_embed(args: argparse.Namespace) -> int:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -118,7 +118,7 @@
             f"Method {args.method} is not applicable on {args.output} at "
             f"{args.position}."
         )
-        return 5
+        return 6
 
     pdf_bytes = apply_watermark(
         method=args.method,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -118,7 +118,7 @@
             f"Method {args.method} is not applicable on {args.output} at "
             f"{args.position}."
         )
-        return 5
+        return 4
 
     pdf_bytes = apply_watermark(
         method=args.method,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -131,7 +131,7 @@
     with open(args.output, "wb") as fh:
         fh.write(pdf_bytes)
     print(f"Wrote watermarked PDF -> {args.output}")
-    return 0
+    return 1
 
 
 def cmd_extract(args: argparse.Namespace) -> int:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -131,7 +131,7 @@
     with open(args.output, "wb") as fh:
         fh.write(pdf_bytes)
     print(f"Wrote watermarked PDF -> {args.output}")
-    return 0
+    return -1
 
 
 def cmd_extract(args: argparse.Namespace) -> int:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -143,7 +143,7 @@
         print(f"Wrote secret -> {args.out}")
     else:
         print(secret)
-    return 0
+    return 1
 
 
 # --------------------
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -143,7 +143,7 @@
         print(f"Wrote secret -> {args.out}")
     else:
         print(secret)
-    return 0
+    return -1
 
 
 # --------------------
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -234,7 +234,7 @@
         return int(args.func(args))
     except FileNotFoundError as e:
         print(f"error: {e}", file=sys.stderr)
-        return 2
+        return 3
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.27s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -234,7 +234,7 @@
         return int(args.func(args))
     except FileNotFoundError as e:
         print(f"error: {e}", file=sys.stderr)
-        return 2
+        return 1
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
         return 2
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -237,7 +237,7 @@
         return 2
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
-        return 2
+        return 3
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
         return 3
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -237,7 +237,7 @@
         return 2
     except ValueError as e:
         print(f"error: {e}", file=sys.stderr)
-        return 2
+        return 1
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
         return 3
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -240,7 +240,7 @@
         return 2
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
-        return 3
+        return 4
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
         return 4
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T162650001088Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T162650921214Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.58s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -240,7 +240,7 @@
         return 2
     except SecretNotFoundError as e:
         print(f"secret not found: {e}", file=sys.stderr)
-        return 3
+        return 2
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
         return 4
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -243,7 +243,7 @@
         return 3
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
-        return 4
+        return 5
     except WatermarkingError as e:
         print(f"watermarking error: {e}", file=sys.stderr)
         return 5
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -243,7 +243,7 @@
         return 3
     except InvalidKeyError as e:
         print(f"invalid key: {e}", file=sys.stderr)
-        return 4
+        return 3
     except WatermarkingError as e:
         print(f"watermarking error: {e}", file=sys.stderr)
         return 5
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -246,7 +246,7 @@
         return 4
     except WatermarkingError as e:
         print(f"watermarking error: {e}", file=sys.stderr)
-        return 5
+        return 6
 
 
 if __name__ == "__main__":
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T143102456024Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T143103261441Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.39s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -246,7 +246,7 @@
         return 4
     except WatermarkingError as e:
         print(f"watermarking error: {e}", file=sys.stderr)
-        return 5
+        return 4
 
 
 if __name__ == "__main__":
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- awatermarking_cli.py
+++ bwatermarking_cli.py
@@ -92,7 +92,7 @@
 
 
 def cmd_methods(_args: argparse.Namespace) -> int:
-    for name in sorted(METHODS):
+    for name in []:
         print(name)
     return 0
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes + bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for +: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E92F8175C0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001E92E749400>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes + bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E92F817B30>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001E92E749400>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1471/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes + bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001E92F841A30>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes + bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001E92F841400>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp541yo1f0.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp541yo1f0.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes + bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001E92F840EF0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes + bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001E92F841AF0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes + bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001E92F841E20>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes + bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 20.04s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str + os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for +: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000024828DFB380>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000024827DBAB40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str + os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000024828DFB8F0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000024827DBAB40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-737/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str + os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000024828E211C0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpwz5sbw20.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpwz5sbw20.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str + os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 19.82s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes - bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for -: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000029A73557680>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000029A7247D370>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes - bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000029A73557BF0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000029A7247D370>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-206/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes - bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000029A73581AC0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes - bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000029A73581490>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp_ohprknt.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp_ohprknt.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes - bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000029A73580F80>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes - bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000029A73581B80>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes - bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000029A73581EB0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes - bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 19.94s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str - os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for -: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F2EE7A7830>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001F2EBC53B30>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str - os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F2EE7A7DA0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001F2EBC53B30>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1501/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str - os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F2EE7CD6A0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp71cayi2u.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp71cayi2u.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str - os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 19.99s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes * bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for *: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F35006B560>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001F34F080050>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes * bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F35006BAD0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001F34F080050>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1889/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes * bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F3500919D0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes * bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F3500913A0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpw94wcoa8.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpw94wcoa8.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes * bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F350090E90>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes * bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F350091A90>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes * bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F350091DC0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes * bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 19.87s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str * os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for *: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BFA8AAB680>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001BFA66A0E60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str * os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BFA8AABBF0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001BFA66A0E60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1243/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str * os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001BFA8AD1460>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmphanaev60.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmphanaev60.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str * os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for *: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 19.87s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes / bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for /: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C206F47710>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001C20304D6D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes / bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C206F47C80>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001C20304D6D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1458/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes / bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001C206F6DBB0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes / bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001C206F6D580>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpkvmxhl7s.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpkvmxhl7s.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes / bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001C206F6D070>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes / bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001C206F6DC70>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes / bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001C206F6DFA0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes / bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 19.87s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str / os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for /: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000283F05B7770>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000283EF4E93D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str / os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000283F05B7CE0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000283EF4E93D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1693/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str / os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000283F05DD580>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpaxn6cvlb.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpaxn6cvlb.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str / os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 20.07s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes // bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for //: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022E098D76E0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022E088094F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes // bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022E098D7C50>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022E088094F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-929/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes // bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000022E09901B50>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes // bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000022E09901520>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmph08c2gag.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmph08c2gag.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes // bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000022E09901010>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes // bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000022E09901C10>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes // bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000022E09901F40>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes // bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 19.90s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str // os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for //: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000023DEF507770>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023DEE4493A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str // os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000023DEF507CE0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023DEE4493A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2054/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str // os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000023DEF52D610>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpphy6h2d6.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpphy6h2d6.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str // os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 19.79s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.64s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150857571035Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150858390812Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.69s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes % bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.FFF.F.F.FFF.FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215014097769Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215015016033Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000024EBB40B5C0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000024EBA36AC00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes % bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000024EBB40BB30>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000024EBA36AC00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2008/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes % bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000024EBB431A60>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes % bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000024EBB431430>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpet6kz4ep.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpet6kz4ep.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes % bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000024EBB430F20>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes % bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000024EBB431B20>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes % bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000024EBB431E50>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes % bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

17 failed, 19 passed, 6 skipped, 23 warnings in 19.62s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str % os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for %: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001CFBCC2B6B0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001CFBBB5D220>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str % os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001CFBCC2BC20>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001CFBBB5D220>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1279/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str % os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001CFBCC51550>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpf6b3bfsl.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpf6b3bfsl.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str % os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 19.85s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes ** bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for ** or pow(): 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000028F1B1E7800>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000028F1A2104D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ** bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000028F1B1E7D70>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000028F1A2104D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-781/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ** bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000028F1B20DBE0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ** bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000028F1B20D5B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpsh7vwpwq.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpsh7vwpwq.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ** bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000028F1B20D0A0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ** bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000028F1B20DCA0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ** bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000028F1B20DFD0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ** bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 20.17s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str ** os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for ** or pow(): 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000020F3F59B560>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000020F3D1E0500>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str ** os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000020F3F59BAD0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000020F3D1E0500>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-693/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str ** os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000020F3F5C1400>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpz4tl279t.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpz4tl279t.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str ** os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 19.80s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes >> bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for >>: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002861F9F77A0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002861E939460>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes >> bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002861F9F7D10>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002861E939460>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1699/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes >> bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002861FA1DBE0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes >> bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002861FA1D5B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmptv6jixqe.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmptv6jixqe.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes >> bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002861FA1D0A0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes >> bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002861FA1DCA0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes >> bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002861FA1DFD0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes >> bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 19.98s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str >> os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for >>: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000184B74676B0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000184B63CEC00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str >> os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000184B7467C20>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000184B63CEC00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1964/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str >> os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000184B7491550>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp34_bprkb.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp34_bprkb.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str >> os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 19.82s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes << bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.FFFFFFF.FFF.FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150339793352Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150340701502Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002402B5F77A0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002402889F650>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes << bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002402B5F7D10>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002402889F650>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-901/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes << bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002402B61DC10>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes << bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002402B61D5E0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmps9esmb_q.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmps9esmb_q.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes << bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002402B61D0D0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes << bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002402B61DCD0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes << bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002402B61E000>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes << bytearray):

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

19 failed, 17 passed, 6 skipped, 23 warnings in 19.42s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str << os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for <<: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E6EE047740>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001E6EB561340>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str << os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E6EE047CB0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001E6EB561340>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1167/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str << os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001E6EE06D550>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp0xaoovxj.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp0xaoovxj.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str << os.PathLike):

                             ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 19.92s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.18s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.61s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes & bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.FFF.F.F.FFF.FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T160048948533Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T160049858000Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001D89D307740>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D89C22D280>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes & bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001D89D307CB0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D89C22D280>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1057/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes & bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D89D32DB80>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes & bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D89D32D550>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpgcq3w1o3.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpgcq3w1o3.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes & bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D89D32D040>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes & bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D89D32DC40>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes & bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D89D32DF70>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes & bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

17 failed, 19 passed, 6 skipped, 23 warnings in 19.66s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str & os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for &: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F2BB2B7830>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001F2BA1F95E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str & os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F2BB2B7DA0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001F2BA1F95E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-173/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str & os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F2BB2DD6D0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpkf1v1ffn.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpkf1v1ffn.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str & os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 20.00s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if isinstance(src, bytes ^ bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for ^: 'type' and 'type'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000204A17A7650>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000204A06DCEC0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ^ bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'type'



watermarking_method.py:98: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000204A17A7BC0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000204A06DCEC0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2384/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ^ bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'type'



watermarking_method.py:98: TypeError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000204A17D1A00>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ^ bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'type'



watermarking_method.py:98: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000204A17D13D0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmprog_kl0q.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmprog_kl0q.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ^ bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'type'



watermarking_method.py:98: TypeError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000204A17D0EC0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ^ bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'type'



watermarking_method.py:98: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000204A17D1AC0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ^ bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'type'



watermarking_method.py:98: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000204A17D1DF0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

>       if isinstance(src, bytes ^ bytearray):

                           ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'type'



watermarking_method.py:98: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 20.16s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -97,7 +97,7 @@
     """
     if isinstance(src, bytes | bytearray):
         data = bytes(src)
-    elif isinstance(src, str | os.PathLike):
+    elif isinstance(src, str ^ os.PathLike):
         with open(os.fspath(src), "rb") as fh:
             data = fh.read()
     elif hasattr(src, "read"):
.........FF..FFs.ssFssFs...........F......                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: unsupported operand type(s) for ^: 'type' and 'ABCMeta'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000273A2197770>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000273A151AC90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str ^ os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000273A2197CE0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000273A151AC90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-766/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str ^ os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000273A21BD5B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpopou6v_6.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpopou6v_6.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

>       elif isinstance(src, str ^ os.PathLike):

                             ^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'type' and 'ABCMeta'



watermarking_method.py:100: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

7 failed, 29 passed, 6 skipped, 23 warnings in 20.06s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -161,7 +161,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         """Return a new PDF with an embedded watermark.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.34s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -200,7 +200,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         """Return whether the method is applicable on this specific method
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -106,7 +106,7 @@
     else:
         raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")
 
-    if not is_pdf_bytes(data):
+    if  is_pdf_bytes(data):
         raise ValueError("Input does not look like a valid PDF (missing %PDF header)")
     return data
 
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: Input does not look like a valid PDF (missing %PDF header)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001D106E7B6E0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D105D9CFE0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if  is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001D106E7BC50>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D105D9CFE0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-966/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if  is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D106EA1BB0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if  is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D106EA1580>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpydms73jc.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpydms73jc.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if  is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D106EA1070>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if  is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D106EA1C70>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if  is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D106EA1FA0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if  is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 20.10s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -95,7 +95,7 @@
     ValueError
         If the resolved bytes do not appear to be a PDF file.
     """
-    if isinstance(src, bytes | bytearray):
+    if not isinstance(src, bytes | bytearray):
         data = bytes(src)
     elif isinstance(src, str | os.PathLike):
         with open(os.fspath(src), "rb") as fh:
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: string argument without an encoding

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001D882437830>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D88137D2B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if not isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001D882437DA0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D88137D2B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-314/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if not isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D88245DD00>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if not isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

>           raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

E           TypeError: Unsupported PdfSource; expected bytes, path, or binary IO



watermarking_method.py:107: TypeError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D88245D6D0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmplqk4nwp5.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmplqk4nwp5.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if not isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D88245D1C0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if not isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

>           raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

E           TypeError: Unsupported PdfSource; expected bytes, path, or binary IO



watermarking_method.py:107: TypeError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D88245DDC0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if not isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

>           raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

E           TypeError: Unsupported PdfSource; expected bytes, path, or binary IO



watermarking_method.py:107: TypeError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001D88245E0F0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if not isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

>           raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

E           TypeError: Unsupported PdfSource; expected bytes, path, or binary IO



watermarking_method.py:107: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 20.11s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -106,7 +106,7 @@
     else:
         raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")
 
-    if not is_pdf_bytes(data):
+    if not not is_pdf_bytes(data):
         raise ValueError("Input does not look like a valid PDF (missing %PDF header)")
     return data
 
.........FF..FFs.ssFssFs..........FFFF.F..                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: Input does not look like a valid PDF (missing %PDF header)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000229EE24B530>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000229ED17D040>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000229EE24BAA0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000229ED17D040>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1466/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:95: in add_watermark

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

___________ TestWatermarkingUtils.test_explore_pdf_basic_structure ____________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000229EE271970>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_basic_structure(self, sample_pdf_bytes):

        """Test explore_pdf returns expected structure."""

>       result = WMUtils.explore_pdf(sample_pdf_bytes)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:160: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

______________ TestWatermarkingUtils.test_explore_pdf_with_path _______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000229EE271340>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp8mi3ty7y.pdf')



    def test_explore_pdf_with_path(self, sample_pdf_path):

        """Test explore_pdf with file path."""

>       result = WMUtils.explore_pdf(sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:177: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp8mi3ty7y.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

_________ TestWatermarkingUtils.test_explore_pdf_with_fitz_available __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000229EE270E30>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_with_fitz_available(self, sample_pdf_bytes):

        """Test explore_pdf when PyMuPDF (fitz) is available."""

        # Mock the import inside the function

        with patch.dict("sys.modules", {"fitz": Mock()}):

            import sys

    

            mock_fitz = sys.modules["fitz"]

    

            # Mock fitz document

            mock_doc = Mock()

            mock_doc.page_count = 1

            mock_doc.load_page.return_value.bound.return_value = [0, 0, 612, 792]

            mock_doc.xref_length.return_value = 4

            mock_doc.xref_object.return_value = "<< /Type /Catalog >>"

            mock_doc.xref_is_stream.return_value = False

    

            mock_fitz.open.return_value = mock_doc

    

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:201: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000229EE271A30>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

__________ TestWatermarkingUtils.test_pdf_exploration_deterministic ___________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000229EE271D60>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_pdf_exploration_deterministic(self, sample_pdf_bytes):

        """Test that PDF exploration is deterministic."""

>       result1 = WMUtils.explore_pdf(sample_pdf_bytes)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:235: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:161: in explore_pdf

    data = load_pdf_bytes(pdf)

           ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_basic_structure

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_path

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_with_fitz_available

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_pdf_exploration_deterministic

11 failed, 25 passed, 6 skipped, 23 warnings in 19.89s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -138,8 +138,6 @@
     #: Concrete implementations should override this with a short name
     #: (e.g., "toy-eof", "xmp-metadata", "object-stream").
     name: ClassVar[str] = "abstract"
-
-    @staticmethod
     @abstractmethod
     def get_usage() -> str:
         """Return a a string containing a description of the expected usage.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -140,7 +140,6 @@
     name: ClassVar[str] = "abstract"
 
     @staticmethod
-    @abstractmethod
     def get_usage() -> str:
         """Return a a string containing a description of the expected usage.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/RemoveDecorator, occurrence: 2
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -153,8 +153,6 @@
             Usage description.
         """
         raise NotImplementedError
-
-    @abstractmethod
     def add_watermark(
         self,
         pdf: PdfSource,
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T005159810108Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T005200785165Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.42s

operator: core/RemoveDecorator, occurrence: 3
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -195,8 +195,6 @@
             If inputs are invalid (e.g., not a PDF or empty secret).
         """
         raise NotImplementedError
-
-    @abstractmethod
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/RemoveDecorator, occurrence: 4
--- mutation diff ---
--- awatermarking_method.py
+++ bwatermarking_method.py
@@ -229,8 +229,6 @@
             If inputs are invalid (e.g., not a PDF or empty secret).
         """
         raise NotImplementedError
-
-    @abstractmethod
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         """Extract and return the embedded secret from ``pdf``.
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T222905626416Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T222906479765Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.43s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) - amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) - 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) - 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) - value
 
     def render(self) -> str:
         # Prometheus histogram:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' - v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') - '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) - "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) * amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) * 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) * 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) * value
 
     def render(self) -> str:
         # Prometheus histogram:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' * v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') * '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) * "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) / amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T111258736657Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T111259595739Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.58s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) / 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T115703129290Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T115704046941Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) / 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) / value
 
     def render(self) -> str:
         # Prometheus histogram:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' / v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') / '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) / "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) // amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.98s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) // 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) // 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) // value
 
     def render(self) -> str:
         # Prometheus histogram:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' // v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T095258668874Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T095259512544Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') // '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) // "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.33s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) % amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) % 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) % 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) % value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T110400135005Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T110401128688Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' % v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') % '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) % "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) ** amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T200241392056Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T200242283727Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.68s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) ** 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T163901125833Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T163901970057Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) ** 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.36s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) ** value
 
     def render(self) -> str:
         # Prometheus histogram:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' ** v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.07s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') ** '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) ** "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.88s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) >> amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) >> amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) >> amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) >> amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) >> amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 38 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) >> 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) >> 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) >> value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for >>: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...ogin_select',), 0.5): 1, (('login_select',), 1): 1, (('login_select',), 2.5): 1, (('login_select',), inf): 1}, sums={})

value = 0.13282394409179688, label_values = ('login_select',)

labels = ('login_select',), b = 2.5, inf_key = (('login_select',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) >> value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 1, (('insert_document',), 1): 1, (('insert_document',), 2.5): 1, (('insert_document',), inf): 1}, sums={})

value = 0.049324750900268555, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) >> value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for >>: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for >>: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 2, (('insert_document',), 1): 2, (('insert_document',), 2.5): 2, (('insert_document',), inf): 2}, sums={})

value = 0.04786825180053711, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) >> value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for >>: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

5 failed, 37 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' >> v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') >> '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) >> "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) << amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) << amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) << amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) << amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) << amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 38 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) << 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T095320659499Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T095321606514Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) << 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) << value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for <<: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...ogin_select',), 0.5): 1, (('login_select',), 1): 1, (('login_select',), 2.5): 1, (('login_select',), inf): 1}, sums={})

value = 0.11977720260620117, label_values = ('login_select',)

labels = ('login_select',), b = 2.5, inf_key = (('login_select',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) << value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 1, (('insert_document',), 1): 1, (('insert_document',), 2.5): 1, (('insert_document',), inf): 1}, sums={})

value = 0.08319687843322754, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) << value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for <<: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for <<: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 2, (('insert_document',), 1): 2, (('insert_document',), 2.5): 2, (('insert_document',), inf): 2}, sums={})

value = 0.06415152549743652, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) << value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for <<: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

5 failed, 37 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' << v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') << '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) << "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) | amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) | amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) | amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) | amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) | amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 38 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) | 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) | 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.41s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) | value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for |: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...ogin_select',), 0.5): 1, (('login_select',), 1): 1, (('login_select',), 2.5): 1, (('login_select',), inf): 1}, sums={})

value = 0.1242227554321289, label_values = ('login_select',)

labels = ('login_select',), b = 2.5, inf_key = (('login_select',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) | value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 1, (('insert_document',), 1): 1, (('insert_document',), 2.5): 1, (('insert_document',), inf): 1}, sums={})

value = 0.0498652458190918, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) | value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for |: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for |: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 2, (('insert_document',), 1): 2, (('insert_document',), 2.5): 2, (('insert_document',), inf): 2}, sums={})

value = 0.05294060707092285, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) | value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for |: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

5 failed, 37 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' | v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.37s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') | '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) | "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) & amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) & amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) & amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) & amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) & amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 38 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) & 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) & 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) & value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for &: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...ogin_select',), 0.5): 1, (('login_select',), 1): 1, (('login_select',), 2.5): 1, (('login_select',), inf): 1}, sums={})

value = 0.10856175422668457, label_values = ('login_select',)

labels = ('login_select',), b = 2.5, inf_key = (('login_select',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) & value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 1, (('insert_document',), 1): 1, (('insert_document',), 2.5): 1, (('insert_document',), inf): 1}, sums={})

value = 0.03545260429382324, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) & value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for &: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for &: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 2, (('insert_document',), 1): 2, (('insert_document',), 2.5): 2, (('insert_document',), inf): 2}, sums={})

value = 0.05100846290588379, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) & value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for &: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

5 failed, 37 passed, 23 warnings in 20.74s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' & v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') & '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) & "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 0.0) ^ amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) ^ amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) ^ amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',), key = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) ^ amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = (), key = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) != len(self.label_names):  # defensive

            raise ValueError("Label cardinality mismatch")

        key = tuple(label_values)

>       self.values[key] = self.values.get(key, 0.0) ^ amount

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:40: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

4 failed, 38 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) ^ 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) ^ 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 0.0) ^ value
 
     def render(self) -> str:
         # Prometheus histogram:
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for ^: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...ogin_select',), 0.5): 1, (('login_select',), 1): 1, (('login_select',), 2.5): 1, (('login_select',), inf): 1}, sums={})

value = 0.10797476768493652, label_values = ('login_select',)

labels = ('login_select',), b = 2.5, inf_key = (('login_select',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) ^ value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 1, (('insert_document',), 1): 1, (('insert_document',), 2.5): 1, (('insert_document',), inf): 1}, sums={})

value = 0.0342707633972168, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) ^ value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'float' and 'float'

WARNING  server:server.py:160 after_request instrumentation failed: unsupported operand type(s) for ^: 'float' and 'float'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...nt',), 0.5): 2, (('insert_document',), 1): 2, (('insert_document',), 2.5): 2, (('insert_document',), inf): 2}, sums={})

value = 0.033750295639038086, label_values = ('insert_document',)

labels = ('insert_document',), b = 2.5, inf_key = (('insert_document',), inf)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) != len(self.label_names):

            raise ValueError("Label cardinality mismatch")

        labels = tuple(label_values)

        # Increment every bucket whose upper bound is >= value so that

        # stored counts are already cumulative (Prometheus expectation).

        for b in self.buckets:

            if value <= b:

                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1

        # Always increment +Inf bucket count

        inf_key = (labels, float("inf"))

        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1

>       self.sums[labels] = self.sums.get(labels, 0.0) ^ value

                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



observability.py:76: TypeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: unsupported operand type(s) for ^: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

5 failed, 37 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' ^ v.replace('"', '\\"') + '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.36s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -107,7 +107,7 @@
 
 
 def _quote(v: str) -> str:
-    return '"' + v.replace('"', '\\"') + '"'
+    return '"' + v.replace('"', '\\"') ^ '"'
 
 
 _lock = Lock()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.31s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -319,7 +319,7 @@
 
 def render_prometheus() -> str:
     parts = [m.render() for m in _ALL]  # type: ignore[attr-defined]
-    return "\n".join(parts) + "\n"
+    return "\n".join(parts) ^ "\n"
 
 
 # Convenience timer context manager (not widely used yet, but available)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() + self._start
         return False
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.55s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() * self._start
         return False
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() / self._start
         return False
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133716887671Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133717780844Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.68s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() // self._start
         return False
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T174732394530Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T174733259938Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.24s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() % self._start
         return False
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() ** self._start
         return False
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() >> self._start
         return False
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() << self._start
         return False
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() | self._start
         return False
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.55s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() & self._start
         return False
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -329,6 +329,6 @@
         return self
 
     def __exit__(self):
-        self.elapsed = time() - self._start
+        self.elapsed = time() ^ self._start
         return False
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int + None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int - None) -> None:
     if size is None or size < 0:
         return
     with _lock:
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125351661098Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125352556703Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.55s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int * None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int / None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int // None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int % None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int ** None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int >> None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int << None) -> None:
     if size is None or size < 0:
         return
     with _lock:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int & None) -> None:
     if size is None or size < 0:
         return
     with _lock:
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T122132641215Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T122133727259Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -259,7 +259,7 @@
         INFLIGHT.inc(route)
 
 
-def observe_request_size(method: str, route: str, size: int | None) -> None:
+def observe_request_size(method: str, route: str, size: int ^ None) -> None:
     if size is None or size < 0:
         return
     with _lock:
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150630589590Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150631483440Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.38s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) == len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) == len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) == len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) == len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) == len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - ValueError: Label c...

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

4 failed, 38 passed, 23 warnings in 20.97s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) == len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.10580921173095703, label_values = ('login_select',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) == len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.04967784881591797, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) == len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.0800013542175293, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) == len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

5 failed, 37 passed, 23 warnings in 20.88s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) < len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) < len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150814624712Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150815498322Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.37s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) <= len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) <= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) <= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) <= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) <= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - ValueError: Label c...

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

4 failed, 38 passed, 23 warnings in 20.79s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) <= len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.12454390525817871, label_values = ('login_select',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) <= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.0481715202331543, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) <= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.05330085754394531, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) <= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

5 failed, 37 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) > len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) > len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) >= len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) >= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) >= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) >= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) >= len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - ValueError: Label c...

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

4 failed, 38 passed, 23 warnings in 20.87s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) >= len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.1242680549621582, label_values = ('login_select',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) >= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.03498554229736328, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) >= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.04996514320373535, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) >= len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

5 failed, 37 passed, 23 warnings in 21.00s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) is len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) is len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) is len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) is len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if len(label_values) is len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - ValueError: Label c...

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

4 failed, 38 passed, 23 warnings in 20.77s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) is len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.10778403282165527, label_values = ('login_select',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) is len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.047585487365722656, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) is len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.05627775192260742, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if len(label_values) is len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

5 failed, 37 passed, 23 warnings in 20.71s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if len(label_values) is not len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.42s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if len(label_values) is not len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.49s

operator: core/ReplaceComparisonOperator_Lt_Eq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size == 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceComparisonOperator_Lt_NotEq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size != 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.63s

operator: core/ReplaceComparisonOperator_Lt_LtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size <= 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceComparisonOperator_Lt_Gt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size > 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.30s

operator: core/ReplaceComparisonOperator_Lt_GtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size >= 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value == b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value != b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value < b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value > b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value >= b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceComparisonOperator_LtE_Is, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value is b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_LtE_IsNot, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if value is not b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is not None or size < 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -34,7 +34,7 @@
     label_names: tuple[str, ...]
 
     def inc(self, *label_values: str, amount: float = 1.0) -> None:
-        if len(label_values) != len(self.label_names):  # defensive
+        if not len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
         self.values[key] = self.values.get(key, 0.0) + amount
..FF.....FF...............................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:288: in login

    inc_login_success()

observability.py:276: in inc_login_success

    LOGIN_SUCCESSES.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_login_successes_total', help='Successful logins', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if not len(label_values) != len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if not len(label_values) != len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1115: in create_watermark

    inc_watermark_created(method)

observability.py:281: in inc_watermark_created

    WATERMARK_CREATED.inc(method)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_watermarks_created_total', help='Watermarks created', values={}, label_names=('method',))

amount = 1.0, label_values = ('robust-xmp',)



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if not len(label_values) != len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:411: in upload_document

    inc_upload(int(row.size))

observability.py:301: in inc_upload

    UPLOADS.inc()

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = CounterMetric(name='tatou_uploads_total', help='Number of PDF uploads', values={}, label_names=())

amount = 1.0, label_values = ()



    def inc(self, *label_values: str, amount: float = 1.0) -> None:

        if not len(label_values) != len(self.label_names):  # defensive

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:38: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:149 before_request instrumentation failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - ValueError: Label c...

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

4 failed, 38 passed, 23 warnings in 21.13s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -62,7 +62,7 @@
     sums: dict[tuple[str, ...], float]
 
     def observe(self, value: float, *label_values: str) -> None:
-        if len(label_values) != len(self.label_names):
+        if not len(label_values) != len(self.label_names):
             raise ValueError("Label cardinality mismatch")
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
.FFF.....FF...............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:236 Database error in create_user: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:284: in login

    observe_db_latency("login_select", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.1065375804901123, label_values = ('login_select',)



    def observe(self, value: float, *label_values: str) -> None:

        if not len(label_values) != len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.06609392166137695, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if not len(label_values) != len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Label cardinality mismatch

WARNING  server:server.py:160 after_request instrumentation failed: Label cardinality mismatch

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:401: in upload_document

    observe_db_latency("insert_document", time.time() - start_db)

observability.py:317: in observe_db_latency

    DB_QUERY_LATENCY.observe(duration, op)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = HistogramMetric(name='tatou_db_query_duration_seconds', help='Duration of DB operations (best-effort manual instrument...n)', label_names=('operation',), buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5), counts={}, sums={})

value = 0.03454089164733887, label_values = ('insert_document',)



    def observe(self, value: float, *label_values: str) -> None:

        if not len(label_values) != len(self.label_names):

>           raise ValueError("Label cardinality mismatch")

E           ValueError: Label cardinality mismatch



observability.py:66: ValueError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:147 Request size capture failed: Label cardinality mismatch

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - ValueError: Label cardinality ...

FAILED ..\test\test_api.py::test_upload_document_route - ValueError: Label ca...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - ValueError: Label car...

5 failed, 37 passed, 23 warnings in 20.80s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -68,7 +68,7 @@
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
-            if value <= b:
+            if not value <= b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T165640621713Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T165641478240Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.68s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -250,7 +250,7 @@
         REQUEST_LATENCY.observe(duration, method, route)
         # decrement in-flight if previously incremented
         key = (route,)
-        if INFLIGHT.values.get(key):
+        if not INFLIGHT.values.get(key):
             INFLIGHT.values[key] -= 1
 
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if not size is None or size < 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -25,7 +25,7 @@
 from time import time
 
 
-@dataclass(slots=True)
+@dataclass(slots=False)
 class CounterMetric:
     name: str
     help: str
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T130132707529Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T130133575951Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.41s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -44,7 +44,7 @@
         for labels, value in sorted(self.values.items()):
             label_frag = ",".join(
                 f"{k}={_quote(v)}"
-                for k, v in zip(self.label_names, labels, strict=True)
+                for k, v in zip(self.label_names, labels, strict=False)
             )
             lines.append(f"{self.name}{{{label_frag}}} {value}")
         return "\n".join(lines)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.12s

operator: core/ReplaceTrueWithFalse, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -50,7 +50,7 @@
         return "\n".join(lines)
 
 
-@dataclass(slots=True)
+@dataclass(slots=False)
 class HistogramMetric:
     name: str
     help: str
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceTrueWithFalse, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -86,7 +86,7 @@
         for labels in label_sets:
             label_frag = ",".join(
                 f"{k}={_quote(v)}"
-                for k, v in zip(self.label_names, labels, strict=True)
+                for k, v in zip(self.label_names, labels, strict=False)
             )
             # Emit stored cumulative counts for each finite bucket
             for b in self.buckets:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.21s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -330,5 +330,5 @@
 
     def __exit__(self):
         self.elapsed = time() - self._start
-        return False
-
+        return True
+
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None and size < 0:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -33,7 +33,7 @@
     values: dict[tuple[str, ...], float]
     label_names: tuple[str, ...]
 
-    def inc(self, *label_values: str, amount: float = 1.0) -> None:
+    def inc(self, *label_values: str, amount: float = 2.0) -> None:
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T214847926228Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T214848768689Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.19s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -33,7 +33,7 @@
     values: dict[tuple[str, ...], float]
     label_names: tuple[str, ...]
 
-    def inc(self, *label_values: str, amount: float = 1.0) -> None:
+    def inc(self, *label_values: str, amount: float = 0.0) -> None:
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T182304030145Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T182304843246Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.48s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, 1.0) + amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -37,7 +37,7 @@
         if len(label_values) != len(self.label_names):  # defensive
             raise ValueError("Label cardinality mismatch")
         key = tuple(label_values)
-        self.values[key] = self.values.get(key, 0.0) + amount
+        self.values[key] = self.values.get(key, -1.0) + amount
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.26s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 1) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), -1) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 2
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.80s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -69,7 +69,7 @@
         # stored counts are already cumulative (Prometheus expectation).
         for b in self.buckets:
             if value <= b:
-                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
+                self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 0
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 1) + 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, -1) + 1
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) + 2
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -72,7 +72,7 @@
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
-        self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
+        self.counts[inf_key] = self.counts.get(inf_key, 0) + 0
         self.sums[labels] = self.sums.get(labels, 0.0) + value
 
     def render(self) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, 1.0) + value
 
     def render(self) -> str:
         # Prometheus histogram:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -73,7 +73,7 @@
         # Always increment +Inf bucket count
         inf_key = (labels, float("inf"))
         self.counts[inf_key] = self.counts.get(inf_key, 0) + 1
-        self.sums[labels] = self.sums.get(labels, 0.0) + value
+        self.sums[labels] = self.sums.get(labels, -1.0) + value
 
     def render(self) -> str:
         # Prometheus histogram:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -90,7 +90,7 @@
             )
             # Emit stored cumulative counts for each finite bucket
             for b in self.buckets:
-                c = self.counts.get((labels, b), 0)
+                c = self.counts.get((labels, b), 1)
                 lines.append(
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
                 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -90,7 +90,7 @@
             )
             # Emit stored cumulative counts for each finite bucket
             for b in self.buckets:
-                c = self.counts.get((labels, b), 0)
+                c = self.counts.get((labels, b), -1)
                 lines.append(
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
                 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -95,7 +95,7 @@
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
                 )
             # +Inf bucket / total
-            total = self.counts.get((labels, float("inf")), 0)
+            total = self.counts.get((labels, float("inf")), 1)
             lines.append(
                 f"{self.name}_bucket{{{label_frag},le={_quote('+Inf')}}} {total}"
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -95,7 +95,7 @@
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
                 )
             # +Inf bucket / total
-            total = self.counts.get((labels, float("inf")), 0)
+            total = self.counts.get((labels, float("inf")), -1)
             lines.append(
                 f"{self.name}_bucket{{{label_frag},le={_quote('+Inf')}}} {total}"
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -100,7 +100,7 @@
                 f"{self.name}_bucket{{{label_frag},le={_quote('+Inf')}}} {total}"
             )
             lines.append(
-                f"{self.name}_sum{{{label_frag}}} {self.sums.get(labels, 0.0)}"
+                f"{self.name}_sum{{{label_frag}}} {self.sums.get(labels, 1.0)}"
             )
             lines.append(f"{self.name}_count{{{label_frag}}} {total}")
         return "\n".join(lines)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -100,7 +100,7 @@
                 f"{self.name}_bucket{{{label_frag},le={_quote('+Inf')}}} {total}"
             )
             lines.append(
-                f"{self.name}_sum{{{label_frag}}} {self.sums.get(labels, 0.0)}"
+                f"{self.name}_sum{{{label_frag}}} {self.sums.get(labels, -1.0)}"
             )
             lines.append(f"{self.name}_count{{{label_frag}}} {total}")
         return "\n".join(lines)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=( 1.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=( -0.995, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 1.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, -0.99, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 1.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, -0.975, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 1.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.83s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, -0.95, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.71s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 1.1, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123658305662Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123659207858Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, -0.9, 0.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 1.25, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, -0.75, 0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.66s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 1.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, -0.5, 1.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 2.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0.0, 2.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 36
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 3.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/NumberReplacer, occurrence: 37
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 1.5, 5.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 38
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 6.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 39
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -123,7 +123,7 @@
     name="tatou_http_request_duration_seconds",
     help="Latency in seconds of HTTP requests",
     label_names=("method", "route"),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 4.0),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 40
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=( 1.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 41
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=( -0.999, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 42
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 1.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 43
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, -0.995, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T211301013747Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T211301867012Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.51s

operator: core/NumberReplacer, occurrence: 44
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 1.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 45
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, -0.99, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 46
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 1.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 47
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, -0.975, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 48
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 1.05, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 49
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, -0.95, 0.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 50
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 1.1, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 51
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, -0.9, 0.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 52
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 1.25, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/NumberReplacer, occurrence: 53
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, -0.75, 0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/NumberReplacer, occurrence: 54
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 1.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 55
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, -0.5, 1, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/NumberReplacer, occurrence: 56
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 2, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 57
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0, 2.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 58
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 3.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/NumberReplacer, occurrence: 59
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -191,7 +191,7 @@
     name="tatou_db_query_duration_seconds",
     help="Duration of DB operations (best-effort manual instrumentation)",
     label_names=("operation",),
-    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5),
+    buckets=(0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 1.5),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/NumberReplacer, occurrence: 60
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=( 1.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/NumberReplacer, occurrence: 61
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=( -0.995, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193622825847Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193623709563Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.55s

operator: core/NumberReplacer, occurrence: 62
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 1.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 63
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, -0.99, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 64
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 1.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 65
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, -0.975, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/NumberReplacer, occurrence: 66
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 1.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194515489132Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194516293879Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 20.64s

operator: core/NumberReplacer, occurrence: 67
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, -0.95, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 68
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 1.1, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 69
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, -0.9, 0.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/NumberReplacer, occurrence: 70
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 1.25, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 71
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, -0.75, 0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 72
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 1.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.25s

operator: core/NumberReplacer, occurrence: 73
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, -0.5, 1, 2.5, 5, 10),
     counts={},
     sums={},
 )
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215034578466Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215035515394Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 74
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 2, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/NumberReplacer, occurrence: 75
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0, 2.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.25s

operator: core/NumberReplacer, occurrence: 76
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 3.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 77
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 1.5, 5, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 78
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 6, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 79
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 4, 10),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/NumberReplacer, occurrence: 80
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 11),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/NumberReplacer, occurrence: 81
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -199,7 +199,7 @@
     name="tatou_watermark_duration_seconds",
     help="Duration of watermark application per method",
     label_names=("method",),
-    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
+    buckets=(0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 9),
     counts={},
     sums={},
 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 82
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -207,8 +207,7 @@
     name="tatou_http_request_body_bytes",
     help="Request body sizes in bytes (Content-Length if present)",
     label_names=("method", "route"),
-    buckets=(
-        100,
+    buckets=( 101,
         500,
         1_000,
         5_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/NumberReplacer, occurrence: 83
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -207,8 +207,7 @@
     name="tatou_http_request_body_bytes",
     help="Request body sizes in bytes (Content-Length if present)",
     label_names=("method", "route"),
-    buckets=(
-        100,
+    buckets=( 99,
         500,
         1_000,
         5_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 84
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -208,8 +208,7 @@
     help="Request body sizes in bytes (Content-Length if present)",
     label_names=("method", "route"),
     buckets=(
-        100,
-        500,
+        100, 501,
         1_000,
         5_000,
         10_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.09s

operator: core/NumberReplacer, occurrence: 85
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -208,8 +208,7 @@
     help="Request body sizes in bytes (Content-Length if present)",
     label_names=("method", "route"),
     buckets=(
-        100,
-        500,
+        100, 499,
         1_000,
         5_000,
         10_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/NumberReplacer, occurrence: 86
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -209,8 +209,7 @@
     label_names=("method", "route"),
     buckets=(
         100,
-        500,
-        1_000,
+        500, 1001,
         5_000,
         10_000,
         50_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.34s

operator: core/NumberReplacer, occurrence: 87
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -209,8 +209,7 @@
     label_names=("method", "route"),
     buckets=(
         100,
-        500,
-        1_000,
+        500, 999,
         5_000,
         10_000,
         50_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/NumberReplacer, occurrence: 88
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -210,8 +210,7 @@
     buckets=(
         100,
         500,
-        1_000,
-        5_000,
+        1_000, 5001,
         10_000,
         50_000,
         100_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/NumberReplacer, occurrence: 89
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -210,8 +210,7 @@
     buckets=(
         100,
         500,
-        1_000,
-        5_000,
+        1_000, 4999,
         10_000,
         50_000,
         100_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 90
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -211,8 +211,7 @@
         100,
         500,
         1_000,
-        5_000,
-        10_000,
+        5_000, 10001,
         50_000,
         100_000,
         500_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 91
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -211,8 +211,7 @@
         100,
         500,
         1_000,
-        5_000,
-        10_000,
+        5_000, 9999,
         50_000,
         100_000,
         500_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 92
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -212,8 +212,7 @@
         500,
         1_000,
         5_000,
-        10_000,
-        50_000,
+        10_000, 50001,
         100_000,
         500_000,
         1_000_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 93
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -212,8 +212,7 @@
         500,
         1_000,
         5_000,
-        10_000,
-        50_000,
+        10_000, 49999,
         100_000,
         500_000,
         1_000_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/NumberReplacer, occurrence: 94
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -213,8 +213,7 @@
         1_000,
         5_000,
         10_000,
-        50_000,
-        100_000,
+        50_000, 100001,
         500_000,
         1_000_000,
         5_000_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/NumberReplacer, occurrence: 95
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -213,8 +213,7 @@
         1_000,
         5_000,
         10_000,
-        50_000,
-        100_000,
+        50_000, 99999,
         500_000,
         1_000_000,
         5_000_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/NumberReplacer, occurrence: 96
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -214,8 +214,7 @@
         5_000,
         10_000,
         50_000,
-        100_000,
-        500_000,
+        100_000, 500001,
         1_000_000,
         5_000_000,
         25_000_000,
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T095426026772Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T095426866556Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.41s

operator: core/NumberReplacer, occurrence: 97
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -214,8 +214,7 @@
         5_000,
         10_000,
         50_000,
-        100_000,
-        500_000,
+        100_000, 499999,
         1_000_000,
         5_000_000,
         25_000_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/NumberReplacer, occurrence: 98
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -215,8 +215,7 @@
         10_000,
         50_000,
         100_000,
-        500_000,
-        1_000_000,
+        500_000, 1000001,
         5_000_000,
         25_000_000,
         50_000_000,
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215343745605Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215344581812Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.31s

operator: core/NumberReplacer, occurrence: 99
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -215,8 +215,7 @@
         10_000,
         50_000,
         100_000,
-        500_000,
-        1_000_000,
+        500_000, 999999,
         5_000_000,
         25_000_000,
         50_000_000,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 100
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -216,8 +216,7 @@
         50_000,
         100_000,
         500_000,
-        1_000_000,
-        5_000_000,
+        1_000_000, 5000001,
         25_000_000,
         50_000_000,
     ),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 101
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -216,8 +216,7 @@
         50_000,
         100_000,
         500_000,
-        1_000_000,
-        5_000_000,
+        1_000_000, 4999999,
         25_000_000,
         50_000_000,
     ),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/NumberReplacer, occurrence: 102
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -217,8 +217,7 @@
         100_000,
         500_000,
         1_000_000,
-        5_000_000,
-        25_000_000,
+        5_000_000, 25000001,
         50_000_000,
     ),
     counts={},
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/NumberReplacer, occurrence: 103
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -217,8 +217,7 @@
         100_000,
         500_000,
         1_000_000,
-        5_000_000,
-        25_000_000,
+        5_000_000, 24999999,
         50_000_000,
     ),
     counts={},
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 104
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -218,8 +218,7 @@
         500_000,
         1_000_000,
         5_000_000,
-        25_000_000,
-        50_000_000,
+        25_000_000, 50000001,
     ),
     counts={},
     sums={},
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 105
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -218,8 +218,7 @@
         500_000,
         1_000_000,
         5_000_000,
-        25_000_000,
-        50_000_000,
+        25_000_000, 49999999,
     ),
     counts={},
     sums={},
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 106
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -251,7 +251,7 @@
         # decrement in-flight if previously incremented
         key = (route,)
         if INFLIGHT.values.get(key):
-            INFLIGHT.values[key] -= 1
+            INFLIGHT.values[key] -= 2
 
 
 def inc_inflight(route: str) -> None:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/NumberReplacer, occurrence: 107
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -251,7 +251,7 @@
         # decrement in-flight if previously incremented
         key = (route,)
         if INFLIGHT.values.get(key):
-            INFLIGHT.values[key] -= 1
+            INFLIGHT.values[key] -= 0
 
 
 def inc_inflight(route: str) -> None:
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T204624865337Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T204625733756Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.57s

operator: core/NumberReplacer, occurrence: 108
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size < 1:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T183612758268Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T183613669658Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.62s

operator: core/NumberReplacer, occurrence: 109
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -260,7 +260,7 @@
 
 
 def observe_request_size(method: str, route: str, size: int | None) -> None:
-    if size is None or size < 0:
+    if size is None or size < -1:
         return
     with _lock:
         REQUEST_BODY_SIZE.observe(float(size), method, route)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -23,9 +23,6 @@
 from dataclasses import dataclass
 from threading import Lock
 from time import time
-
-
-@dataclass(slots=True)
 class CounterMetric:
     name: str
     help: str

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:17: in <module>

    from observability import (

observability.py:113: in <module>

    REQUESTS = CounterMetric(

E   TypeError: CounterMetric() takes no arguments

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:41:05+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:41:05+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T00:41:06+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:41:06+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: CounterMetric() takes no arguments

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.11s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -48,9 +48,6 @@
             )
             lines.append(f"{self.name}{{{label_frag}}} {value}")
         return "\n".join(lines)
-
-
-@dataclass(slots=True)
 class HistogramMetric:
     name: str
     help: str

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:17: in <module>

    from observability import (

observability.py:119: in <module>

    REQUEST_LATENCY = HistogramMetric(

E   TypeError: HistogramMetric() takes no arguments

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T02:21:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T02:21:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-18T02:22:00+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T02:22:00+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: HistogramMetric() takes no arguments

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

7 warnings, 1 error in 13.72s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -41,7 +41,7 @@
 
     def render(self) -> str:
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} counter"]
-        for labels, value in sorted(self.values.items()):
+        for labels, value in []:
             label_frag = ",".join(
                 f"{k}={_quote(v)}"
                 for k, v in zip(self.label_names, labels, strict=True)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -67,7 +67,7 @@
         labels = tuple(label_values)
         # Increment every bucket whose upper bound is >= value so that
         # stored counts are already cumulative (Prometheus expectation).
-        for b in self.buckets:
+        for b in []:
             if value <= b:
                 self.counts[(labels, b)] = self.counts.get((labels, b), 0) + 1
         # Always increment +Inf bucket count
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T190032307055Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T190033191259Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.46s

operator: core/ZeroIterationForLoop, occurrence: 2
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -83,7 +83,7 @@
         # <name>_count{...} <total>
         lines = [f"# HELP {self.name} {self.help}", f"# TYPE {self.name} histogram"]
         label_sets = sorted({lbl for (lbl, _le) in self.counts.keys()})
-        for labels in label_sets:
+        for labels in []:
             label_frag = ",".join(
                 f"{k}={_quote(v)}"
                 for k, v in zip(self.label_names, labels, strict=True)
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T190358466367Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T190359371807Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.63s

operator: core/ZeroIterationForLoop, occurrence: 3
--- mutation diff ---
--- aobservability.py
+++ bobservability.py
@@ -89,7 +89,7 @@
                 for k, v in zip(self.label_names, labels, strict=True)
             )
             # Emit stored cumulative counts for each finite bucket
-            for b in self.buckets:
+            for b in []:
                 c = self.counts.get((labels, b), 0)
                 lines.append(
                     f"{self.name}_bucket{{{label_frag},le={_quote(repr(b))}}} {c}"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt - nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for -: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb57e7508abf19a4d: unsupported operand type(s) for -: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026409EF5850>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002640721F650>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002640721F650>

payload = {'id': 'fd5187ba-a971-44e6-9604-3b3cb72a8c2c', 'salt': 'dVQV1Gj3u1gXzx9PAWrNrA==', 'secret': 'unit-test-secret', 'timestamp': 1760729745, ...}

key = b'b}K\xdbN,$\xd7\x05\xa5\xf6w2b\xae\x86\x7f\xb7\xf5\x06\xad\xf0\xde\x0e@\xd1\xa8\xb0u \xf0\x94'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt - nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026409EF7B00>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002640721F650>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1640/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002640721F650>

payload = {'id': '8cb4e156-5ff8-4de0-b7d1-5e6e39e7f888', 'salt': 'f602YZBId1o4jGe/2JooiA==', 'secret': 'unit-test-secret', 'timestamp': 1760729745, ...}

key = b'\xe9\x97+\xa9\xf5\x0c\xbaT\xaa\xf8\xf8E\x8b\xaf\x1bB\x94P\xb9`\xed_%\x14\xcf\x91\x9c\xe4\x91j\xd5\x07'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt - nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000026409F19910>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp930ceftq.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002640721F650>

payload = {'id': '85708f3e-4430-4ac1-8583-51116eef4106', 'salt': 'NdBRAMpl73sdfoL1QQju9Q==', 'secret': 'test-secret', 'timestamp': 1760729746, ...}

key = b'\xce\xe2bB\xcdt\xfeq<\xa5h\xa0\x1d\xd7\xe4\x93\x1d\x14W\xc4\xf7\xb0\xceE\xfb\x93\x0c\xa3\x8ew\xf6\x9e'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt - nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000026409F19AF0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpidosomob.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002640721F650>

payload = {'id': '4c71ec69-dab2-4907-b094-a8c279db5a0d', 'salt': 'fgwYkGd4A+lj7yj9tSoF4A==', 'secret': 'test-secret', 'timestamp': 1760729746, ...}

key = b'\x93\xd8\x17i\xed\xfa\xf8>\x98\xd6\xb5\x14\xb7\xbd\xe1\xa8\x894\xa6b\x8f\x18\xfbS\x0c\nf?>j\xaf\x97'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt - nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce - ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.FFF.F.F.FFF.FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150108747009Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150109572645Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e69b7149109865d80: unsupported operand type(s) for -: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000286BCBC9610>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000286B9E9F380>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000286B9E9F380>

payload = {'id': '6916f0a6-53b0-45e0-a691-e42da21f50c9', 'salt': 'BYgHEM+5WAkd9BbJb1V6HQ==', 'secret': 'unit-test-secret', 'timestamp': 1760713274, ...}

key = b'\x1af\xb6t\x1a\xb1\xc8X\xe8uA\xab\x85\xc1\x8c?\x8b\xca\xb1j\x96\x8a\xf4\xd5I9-Z\xdf\xb9\xcf\xcb'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce - ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000286BCBCB890>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000286B9E9F380>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-894/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000286B9E9F380>

payload = {'id': 'f7812edc-0b1c-4b34-ab81-84d076ef4e5a', 'salt': 'TMz19xVTNlfYN5xI4dwXnA==', 'secret': 'unit-test-secret', 'timestamp': 1760713274, ...}

key = b'+u\xc5\xfc3\xcdf\xbah\xb99\xe2\x1erR\xedv\xe1\x98R<\xa1\x90A\xe1AC\x17H\x01\x92:'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce - ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000286BCBF16D0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpe3hvjpqc.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000286B9E9F380>

payload = {'id': '64cacb21-7ddd-4ac5-9128-f0b61935cd99', 'salt': 'DU9xVV6qvDrAxrcu2RdT/A==', 'secret': 'test-secret', 'timestamp': 1760713275, ...}

key = b'J\x8c\xb8\xd7\x94\xfe\x04%\x05\xbd\x07h\xf6\xfb:J\x7f\xa3\xed\x9c\xaf\xc5q\xcd^\xb8\xa4\xd3~\x11T~'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce - ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000286BCBF18B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpk700_30r.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000286B9E9F380>

payload = {'id': 'f2bf4692-7919-43c9-9ab1-6179d985b8dc', 'salt': 'BFgIubD/6lHT4Ost9o4Edw==', 'secret': 'test-secret', 'timestamp': 1760713275, ...}

key = b'u\xef\xfe\xbfA\x1b\x11\x8a\x14\x89\xf4;\x85\xb8t\xaa\xc3\x8c\xde@\xd0bn\xaef\xb6\xc5v\x8dY\xa8D'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce - ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

14 failed, 28 passed, 23 warnings in 20.46s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT - 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start - fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE - 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE - 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022A5A49E450>

encrypted_payload = 'KYpfPlKjDhLOf+AHLsDMbqsJCeI97PqI0mnNASBpLllJYun3nQN2DXPNeRs5v9wBEdDo7sWGwZtMzlBKvpottCxkKtVCtFUHcV7wcALfOOK7sZ8HpVPna...RG/B3XtRg0yxBuInD+HQurWbY0o73UkAMcfiq9gnBx9PdMix0MNfY9QPLsH2pqzwwtTSBjb7c5QDEDqTkAgIHYFlZfBrl7X4cvRy2dGAhSzFjFpYmLTPXR'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE - 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               ValueError: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:445: ValueError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022A5B61B6E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022A5A49E450>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-898/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022A5A49E450>

encrypted_payload = 'KYpfPlKjDhLOf+AHLsDMbqsJCeI97PqI0mnNASBpLllJYun3nQN2DXPNeRs5v9wBEdDo7sWGwZtMzlBKvpottCxkKtVCtFUHcV7wcALfOOK7sZ8HpVPna...RG/B3XtRg0yxBuInD+HQurWbY0o73UkAMcfiq9gnBx9PdMix0MNfY9QPLsH2pqzwwtTSBjb7c5QDEDqTkAgIHYFlZfBrl7X4cvRy2dGAhSzFjFpYmLTPXR'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE - 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE - 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022562471C40>

encrypted_payload = '50gKJtfanLLotZ9pqZx0XjZ4joSAkGpe8trp1klJbhfbD5C07dnUu246kwSOIjM1WyXKscoVEsonHV054wxY4neucSxagl4c9T4ouR7MYsPtmXPHtj0iO...GfvKKEMftKpF253rYYo0HBjFN3qP2qOe1OOSBE8val6RdICi+gVhWmPI+3lUbDMeIoaE1ueJqbMtitra5EE6ldOgLegzxfZVNik9JKB+YDEqdM2fIlCLEx'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE - 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022564F8B980>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022562471C40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-346/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022562471C40>

encrypted_payload = '50gKJtfanLLotZ9pqZx0XjZ4joSAkGpe8trp1klJbhfbD5C07dnUu246kwSOIjM1WyXKscoVEsonHV054wxY4neucSxagl4c9T4ouR7MYsPtmXPHtj0iO...GfvKKEMftKpF253rYYo0HBjFN3qP2qOe1OOSBE8val6RdICi+gVhWmPI+3lUbDMeIoaE1ueJqbMtitra5EE6ldOgLegzxfZVNik9JKB+YDEqdM2fIlCLEx'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE - 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.39s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt * nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.FFFFFFF.FFF.FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T114345222545Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T114346118066Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e497257a6a5b08aa1: can't multiply sequence by non-int of type 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001FC08AE9640>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FC05DC0FE0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FC05DC0FE0>

payload = {'id': 'a7da5d0e-43c6-42f2-a671-85baad119922', 'salt': 'tGeFsNHJZ5/ZC6RW9rjo6w==', 'secret': 'unit-test-secret', 'timestamp': 1760701431, ...}

key = b'\xa9U\x8c\xc7O/\xa8\xa5\xf4\xd2nt\xf5\xe7~\xaa>\xba\x15\x0e\xa3hH\xf7\xc5\xb9\xf8st\xaata'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt * nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001FC08AEB890>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FC05DC0FE0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-360/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FC05DC0FE0>

payload = {'id': 'b90c9585-8c52-47dd-a87e-6d1225b18626', 'salt': 'QCxJ6KW61g5/otrPz0PrBg==', 'secret': 'unit-test-secret', 'timestamp': 1760701431, ...}

key = b'\x81Lj\x97\xd1_\x899\xe1\xae\x17A\xa35\xb3\xb1 \xe0y"\x0eE\x17l\xb8]\xd9\xd0\xc4f\x9ay'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt * nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001FC08B116D0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpgmbur1ow.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FC05DC0FE0>

payload = {'id': '74cbed01-a691-4440-bb3b-6437b3032d0a', 'salt': '/o0ap/umONaHoW2PvXD5tQ==', 'secret': 'test-secret', 'timestamp': 1760701431, ...}

key = b'`\r\xd1=\xaa\x17\x8f\x9d\xf7\xf8\xb6\xe5\t:Z\xb6r\t\xef\xe2\x96\xa0k?\xdd\xff\xb1\xe7\x04\x15\xc4\xf4'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt * nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001FC08B118B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp7qwlec9l.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FC05DC0FE0>

payload = {'id': 'bb81abb9-fa30-4147-9949-da3b20211ace', 'salt': '2KB+iVWCyQX4koFpT+4Qyw==', 'secret': 'test-secret', 'timestamp': 1760701431, ...}

key = b')\xb2dx\x9ae#\xf1,\x86f\xe9L\x1c\x1c\x8d5\xeb>\xa4\x0f\x89\x01\x86\xdd\xb3(\xc6\xc9\xe3g*'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt * nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

16 failed, 26 passed, 23 warnings in 20.53s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce * ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: can't multiply sequence by non-int of type 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eac4ac5fb05bbe358: can't multiply sequence by non-int of type 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000017D12105760>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017D0F5D1F40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017D0F5D1F40>

payload = {'id': '45739c65-089c-4231-9d2d-98e4ae2821b7', 'salt': 'zad6OQMd3M2QhQcEv/9lZg==', 'secret': 'unit-test-secret', 'timestamp': 1760710901, ...}

key = b'\xbdhWO\xbb\xc7\x1a\xdbE\xba\xd1"Y\xdf\xc5\x98\x89\x92\xf0\xb6\xa8\x7f\xf5B+\xd52\xf9T4\xf2\xd9'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce * ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000017D12107AA0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017D0F5D1F40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-788/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017D0F5D1F40>

payload = {'id': '6224e8e0-7061-4e66-aa2a-1f6dd9dfddfa', 'salt': 'J9sNvNCz8TRYls1kfUkAvw==', 'secret': 'unit-test-secret', 'timestamp': 1760710901, ...}

key = b'VqgJ\xde\xf8\xee\xb6\xf6\x99\xf0\xe15;\x9d\x9d4\x04\x11\xd2\x0b\xe3\x9c\x1e\x93\xd8K\xf0\x16\xd5\x19\xab'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce * ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000017D1212D910>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpvk2zg46g.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017D0F5D1F40>

payload = {'id': '7a240c42-8aed-464c-8eb8-f9381d9d3edf', 'salt': 'LBUWORvs24L52MJPSVY5BQ==', 'secret': 'test-secret', 'timestamp': 1760710901, ...}

key = b'j\xe3\xda\xc5\x89\xae\xf9\xbe\xa7\x9a\xdb\xd3\xd3-w\xa7\x9eh\xa1\xdf+\xa2\xb2\xa5\xcc\x99\xd0r\x1d\xc3\x9cE'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce * ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000017D1212DAF0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp71vr6ufw.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017D0F5D1F40>

payload = {'id': '05fc1d7b-0828-44c7-a580-6f81ca7bf751', 'salt': 'o7CWgpVaA2dYBsNd3bdi8A==', 'secret': 'test-secret', 'timestamp': 1760710902, ...}

key = b"\xb4\x04\xff\x15\xcc\x94'p\x82Z\x95$\xe1E\xfb\x9cz\xb4\xbdI\xe7o\x16E\xdc\x86w\xb5\xc1h~\xaf"



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce * ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT * 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start * fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE * 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000151D01B79B0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000151CD645040>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2101/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000151CD645040>

encrypted_payload = 'KzyQLx1G7+Xvcwr+TgaE3OkFSOtD64Pgcntp4QhlLFPJeMyxGkYmkqHUXtg+Ea6+THdvHn4HWjE6T3Tl8t/FlvOKYselwLNDECKb+3rwSYetIoSgvltV0...PqownVRHy6OFSw+KDrQc+/HJnKa10vlwskF81AIer5UbRTPj0guB0N+K4AghEmHE91vxvohufzudEzLEYzwUql+ZmYEeeDC2CuOxpkrfoL1lbewrHLRFqq'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE * 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE * 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E46BACBB30>

encrypted_payload = '1FX59pIwwtr4wVNYw/l/VnwCJnbxBst4Gp4Q7o/tnEZvUtX7vy28UcMgjMw01GqTsyfHsjLBRWdO7G3mp/D5dCKS7LlPGcgTR/Lm8ULG7LuyZ8RS4UT8R...v6JzfNiBYmd9BEPJQi1msZ7YDZTAq7ilwk4dPCQ8UOtwspMmA58kiVMxmKQqGvspXppf4yNz0RRCgsnYSZKscS4f+9LkSwZG/7VzUgTTgm/3Sr0lglgraM'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE * 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               ValueError: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:445: ValueError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E46CC2B4D0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E46BACBB30>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1617/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E46BACBB30>

encrypted_payload = '1FX59pIwwtr4wVNYw/l/VnwCJnbxBst4Gp4Q7o/tnEZvUtX7vy28UcMgjMw01GqTsyfHsjLBRWdO7G3mp/D5dCKS7LlPGcgTR/Lm8ULG7LuyZ8RS4UT8R...v6JzfNiBYmd9BEPJQi1msZ7YDZTAq7ilwk4dPCQ8UOtwspMmA58kiVMxmKQqGvspXppf4yNz0RRCgsnYSZKscS4f+9LkSwZG/7VzUgTTgm/3Sr0lglgraM'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE * 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.15s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE * 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000201C1392750>

encrypted_payload = 'FirErIivwj2uP2vgxnDibN2SqpmyLe6DuKuo2pqw2aOHFfdqy8RARTjOefKI1UmDHB+GvJYXy2rY9ETRILw6xJ05Q6zhJtM2LCul2SnNgFdz57fcWfe1u...E4cHz4zn9gZrH+9MkCQfDnVRWg4s3bo9+SZQ8FaQoBSA3hwtao2mFR6NglIVDwQBQacK7P9UQ0Yu8W3ylv91ZmxO5A4uFihVPxrNJWf22BO9KeroZtNZPp'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE * 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000201C37EB5F0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000201C1392750>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1242/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000201C1392750>

encrypted_payload = 'FirErIivwj2uP2vgxnDibN2SqpmyLe6DuKuo2pqw2aOHFfdqy8RARTjOefKI1UmDHB+GvJYXy2rY9ETRILw6xJ05Q6zhJtM2LCul2SnNgFdz57fcWfe1u...E4cHz4zn9gZrH+9MkCQfDnVRWg4s3bo9+SZQ8FaQoBSA3hwtao2mFR6NglIVDwQBQacK7P9UQ0Yu8W3ylv91ZmxO5A4uFihVPxrNJWf22BO9KeroZtNZPp'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE * 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.30s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt / nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for /: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6731dee6d435a8a9: unsupported operand type(s) for /: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000021AB68B55E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021AB3CE1A30>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021AB3CE1A30>

payload = {'id': '78c313a3-ba64-4e8a-a95d-04e127f49fc5', 'salt': 'NmRZA32TiNRFn85DHt8p5A==', 'secret': 'unit-test-secret', 'timestamp': 1760711489, ...}

key = b'+\xf3\x1c\xea2\x87px\xc5Y3\x1d\r\xa4\x03\xa5\x9b{\x10{~$\xab\xfa\xc9\x1d\x9f|\xfb0\x95\xc2'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt / nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000021AB68B7980>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021AB3CE1A30>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-811/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021AB3CE1A30>

payload = {'id': 'bf33d204-a5e4-4639-9462-28708595e0c6', 'salt': '+hbbfWL9bJyVnn4vFisC7g==', 'secret': 'unit-test-secret', 'timestamp': 1760711490, ...}

key = b'\xeb\x82\x19\x06\xb8\xc8\xa3<\xa0\xe5\xaf\xca\x83\x06Q\xb1\xc5\xc6f\x7f!\xc4\xfa\xd6\xbb\xdfM\xb0n\r\xe3G'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt / nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000021AB68DD790>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpweu6e_ze.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021AB3CE1A30>

payload = {'id': 'b10d02aa-bea0-4f6a-8480-fa23f89fa722', 'salt': 'cnlW6ax91844TjOdeQlAYg==', 'secret': 'test-secret', 'timestamp': 1760711490, ...}

key = b']\xd4V&U-+\xbc\x9c\x12\xba\xe6\x83\x8b@\x9e\xfb<\xec&\x0bb\xefb$\xcbA\xad\xc3z"h'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt / nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000021AB68DD970>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp_g4q2xlx.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021AB3CE1A30>

payload = {'id': '9ea606d8-7ce5-4e81-8fdb-eebb1378f30c', 'salt': 'g85/Tq2FLKXlF1i8JpJbYg==', 'secret': 'test-secret', 'timestamp': 1760711490, ...}

key = b'{\x83\\\x83Av\\\x94\xb73\x00+E)\xef\xec\xcdl\x92\xd3\x0c\xfc]\xdb\x9d3U\xd8[ @V'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt / nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce / ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for /: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef384515912261920: unsupported operand type(s) for /: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B8FBD35790>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B8FBBA21B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B8FBBA21B0>

payload = {'id': '71b64d9b-fd26-4565-aa5c-e32514082fef', 'salt': 'GzFxyM7FGff9H9ZR8x4dJA==', 'secret': 'unit-test-secret', 'timestamp': 1760703742, ...}

key = b'\xb4E\x84\x8c\x92\x12\xe1\x88\xc6\x0f\xc3\xb25J[\xad)kC\x10\x0fI\xf2\xeeJ\xca\x15\x01\xb3$\x94\x10'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce / ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B8FBD37AA0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B8FBBA21B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-459/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B8FBBA21B0>

payload = {'id': 'dcbbcc1b-ca7d-4992-978a-83bb844893ac', 'salt': 'xza5W2zKti43VUpfdFwPyg==', 'secret': 'unit-test-secret', 'timestamp': 1760703742, ...}

key = b'\xd4\x19^&:-\xca\xd3\xbd03\x96\xe6\x82\x00\x837\xa8\x1e\xd2\xadN\xda\xe9\xa8\xb0Z\x06Y\xd9H\x0e'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce / ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001B8FBD5D8E0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpt5s88q7h.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B8FBBA21B0>

payload = {'id': '264c9a43-123f-40d1-8005-0394d9791d11', 'salt': 'VOrshYaZsoe1/zuOkdg2uQ==', 'secret': 'test-secret', 'timestamp': 1760703743, ...}

key = b'aJ\xb1\xab\xfa+\xaf.2Z\xad(\xe2\xe4\xda\xa2GS\x11\x059j\x91\x18\xaf`\x14F\xfc.=\x08'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce / ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001B8FBD5DAC0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpdvkmvqn0.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B8FBBA21B0>

payload = {'id': 'bd136f6a-a3e6-4136-ba5b-d7f2e3b6f395', 'salt': 'YpETgMUTD+cqQr547l82tw==', 'secret': 'test-secret', 'timestamp': 1760703743, ...}

key = b'?}\xc9\x8e\xd7"a\x9e\xfb{\x0f\xe9\xb1\xaa\xfd\xca\xa0\x17\xa87\x19\xc5\xae\xebMc\x04~=g\x88\x12'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce / ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 21.26s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT / 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.............FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614edcb4708accee4750: slice indices must be integers or None or have an __index__ method

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019A098B9760>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019A05C5F380>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019A05C5F380>

doc = Document('None', <memory, doc# 11>)

encrypted_payload = 'KflTG0/yRhKf+MzYMYoVp84DX1aZRNEzuAPr09ODOUBkjUfIvQ7X7AxvGG0KstjqCM8zOSQb+9hD61NEotLMDPW6DUx4oMaz8zrCANnr8tetDBNmoCk5u...dJnDQpSndcpPT1kGaZS0yal55X6zhNLGoFhDavFyEMwbnGZ6f2Oj22Ceijm8fFF7FfhV259EOBm90zcwYWFVF0UZgx7RE3WnzDJ4S3wul6Eczd4PxtSaLm'

watermark_id = '6bbd585a-0673-4a6d-acc3-cca610393810'

key = b'mQYR\xe7 \xd9\x98\x16\x80s\xe8\x8e\xc7\xf2\xdb\xc9\xf1=\xd8#\xcc\\m\x8e\xff\xe4\x0f\x03\x1e\xdd:'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT / 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019A098BB7A0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019A05C5F380>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1295/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019A05C5F380>

doc = Document('None', <memory, doc# 17>)

encrypted_payload = 'L254yaI4iPX7zuDElw/c/wMcAL1ccDJVt+lvPFQiFB7MKtTqydmiHeEe14MiStvzeMZ7NuE4ehe2stEc86wHpG/2k25RyTZCDQG1xatfhg92yT8mvbDZq...ydZzZDSXMtzEO4nAlU/m2NhnGVlur084GJbwejpJTF3AxGLI/SKuSCDIfqrERbLPM/m1RajFmrD6D8i2E7j7M7s9xAXxAHOyfrsBpo1jcy0Gy/Fq3FDShK'

watermark_id = '2a3f6dab-ceda-4354-aea8-b5a073e5ec38'

key = b')j\xb5\x9dTF\xf7\x9c\xd1\x01\xab\x12\xf1\xd1\xb9\x04;\x9f5>\xc1\xf2^\xd7i\xf6\xf00k4_s'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT / 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000019A098E15B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpwtia_w08.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019A05C5F380>

doc = Document('None', <memory, doc# 26>)

encrypted_payload = 'VURoM83juGyNKEzrHh02WdNC8/AFz6vuUG5OpYMLKQ0/vlIvrXhRUD2jyNelXyofp2QL3kHRCM4l9nR0EN/uZ5fVLNPX0gur5MZZY1dFlVSXJbN4pdKnm...sZ8cnfkY9u6L1992AIGbTysK9ZmeGsQIdpD+Kp8dK/oEvyW+JU1sY91JTdi7yAI6BAikioaPE0PAGdr2te1/BgDZFkKnwzX/3bkiuQQagX82Dk7zFYBA=='

watermark_id = '2d48b5b8-5da7-4bdd-872e-d4307a725833'

key = b"\xb9\x8e@U@b'v\xa0\xff)\xd6\xe0O\xf2+\xbc\xc54\x0c7\xa7\xd9\x80o\xc8iMq\xe27\xa5"



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT / 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000019A098E1790>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpettoxjbp.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019A05C5F380>

doc = Document('None', <memory, doc# 28>)

encrypted_payload = 'sRbm1euP+r1GQmAuxyfQRZP1Zey/jQTe+DOTXzx9NR1hZPL9IJbMk12GBELXYefWC7sdDKs9Zi0rD+9E5T1vKdBin6BYC7klCTgn/qOJBCcte5CUeJy5n...dDYHhxSEkZb8OxPBaS6dxC5ocINLu5skg0mSwEKZUYZ7Fl2DCEp5IGx6UNwyYkToN0esbpE2Y2s7/A341anhcqTXmWKUs8uNSjU23PgCsvNRtGofXEWQ=='

watermark_id = '6571d6a2-da4a-46f4-9c61-f161a5184142'

key = b'5\xf5\x183\xb5\x1a#\xf7\xe3,\xf0\x00.\xc9\xea\x0cTu\xfe6\xdd\x98jz#\xabE\xa1\xfa\x88B\xa6'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT / 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

6 failed, 36 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start / fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
.............FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e44b9ef6bf157b504: slice indices must be integers or None or have an __index__ method

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F55C265640>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F5592AC950>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F5592AC950>

doc = Document('None', <memory, doc# 11>)

encrypted_payload = 'v7DVPKTLqDRYU3iy2802QsvAxOanTIJ5gWZFaL27bogQar3wV8pDgtbGTEyVEz/Kx8iQEo7V13+Utlz83kE7K2kJLFq0N2K7hADdYvoSvMlVv0A1/QN0l...CVL1YMQ3uQYU+x3mVFMSpF3QtMnOrV2TplXoXh9eG9+rPjfQXnrH2egglfp48XA3HWALPVqWTpAD0aHIwkvr1kPawKUNv42tC/WSZHCRkmBZixClfxRbiU'

watermark_id = '592bc6f1-607a-4a0b-814f-1835d5dfcb9a'

key = b'z2[\xf2}\x7f\x85j\xab\xef&S0\xa9\xd9D2J\xa6\x08\xad\x8asIg\x86k\xfc<n\x82\x1f'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start / fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F55C267AD0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F5592AC950>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1869/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F5592AC950>

doc = Document('None', <memory, doc# 17>)

encrypted_payload = 'Tf2UOy5thgTFUnkbAHI3dbb6jnbKsYtEuWMwDLG5La2aFqJbIc/fcdojDZylVsihMOVhpx0F2fRmofYx5YBlAS9dwZQwFgz+LHEEMQjCeqHVYBfjpcly7...ADkxIc/dTomA8lKabqFKfLhL09RMo3TBAKUp72Dyh/S4z4FgVp+1Ys31bFnpdkDBeQoXAL8576mmm7TOy7jN26zslwMxuzyut61MYpKkmKUva1DkJ6VKMF'

watermark_id = '1dfe47bc-7c69-466f-a7b7-00e8dbd48115'

key = b'\xd0R\xa5\xb7\xf1\xc2#\xce\xa2\x9b,I\xf5*\xcb\x92\xfeuUh|w:\x17\x07\xfa\x81\x86\xb3R\x0e\xa8'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start / fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F55C28D910>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpukugvojb.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F5592AC950>

doc = Document('None', <memory, doc# 26>)

encrypted_payload = 'KTFvxm5pfJ+BN95cm3LdEBqHcQLsr58iUM7DdNpI6rbhCpxlZaNyoZ4H2vKaINHa19Z53302zayZdvSUfyF4GCMeg1yJOt3H23Mm6WbvTEII1HI6SGlLe.../oAWPIgA77l3R43rV/9CZ9BBJvHfTGq4sMDxldyB7jTPRmnbCUpzeUxBtbAdyiCU1ZrHQAxioB1e2gE/kelAbknqdL1V1MrjyjF47SJMAzZZdKpJ2tDw=='

watermark_id = 'ee08ee3c-488f-40a5-8150-7bdf7258172a'

key = b'\x9c\x8cV\xee\xaa\x0f.\xfb\x9b\x17\x982\x04\xcb\x80%\xf5\xc7\x92\x10\x16\x98z\xae\x9a\xdb\x86)\xe1\xaap\xf6'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start / fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F55C28DAF0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp34tvaem9.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F5592AC950>

doc = Document('None', <memory, doc# 28>)

encrypted_payload = 'mHLM2jyYXHoDXvfVxr3mLlPqZb+r6IK7fdBb1XzerFmBcEN6VZJFoxxvWtFkqUUfskbIhRu4xro54h6P0iHLVBqbwtc2sNIlv+BmIlPFdofOsMKL6n2U0...CjABUEmWrO7NjTecOAxiT59dKyysAoST3Plzmy7o1O/pTKSDNST0m1+xyVqlCD2k0IVO65LJ2/kPNDPLVuCpfHDXtj7Sk7fVRLi+vrjeqioMXmjVgTWg=='

watermark_id = '21b7d618-a1e3-4dad-87f9-331583f6481b'

key = b'\xfa\x1c\xc5\x05\t[(\x8b.A\x15\x95\xee\xb8Su\x1e|\xa6B\x19\xc4\x7f\x87\xf6\x8cG\xdf\x95\x0c\xe2\x8e'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start / fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

6 failed, 36 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE / 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE / 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.FFF.F.F.FFF.........F....................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T153222657942Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T153223569146Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EF6381FF50>

encrypted_payload = 'jpLe3hddF2imeUnfU3exza/jzxKXSBaqXMzic5dwlQf1jbfcXtPW31lSLDkmOJeFWtAs33KkKwdNQb4zB8u1NwJAZ/Ufe3aXK2vITVSdSBqBz89b22Z38...1AGEqLjd8OSkiatY8nnSKhdO6IFXByrnLI75xmunrxZWF++rUt+1XDfRt9CGfySawHTRVUQws8WR/WWng7whUa/KV/Bc4L7z4xj2TaeFFwKijNvgqgS7uL'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

>               nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE / 12]

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:437: TypeError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001EF65957A10>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EF6381FF50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-980/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EF6381FF50>

encrypted_payload = 'jpLe3hddF2imeUnfU3exza/jzxKXSBaqXMzic5dwlQf1jbfcXtPW31lSLDkmOJeFWtAs33KkKwdNQb4zB8u1NwJAZ/Ufe3aXK2vITVSdSBqBz89b22Z38...1AGEqLjd8OSkiatY8nnSKhdO6IFXByrnLI75xmunrxZWF++rUt+1XDfRt9CGfySawHTRVUQws8WR/WWng7whUa/KV/Bc4L7z4xj2TaeFFwKijNvgqgS7uL'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE / 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

9 failed, 33 passed, 23 warnings in 20.44s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE / 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002BB425CA1B0>

encrypted_payload = 'IzNgm/Sl2oyNS+UZKPhRCUpzziShqz7/lFn3cCDJpX1deHKoSggLEYLmyM1YOTa8SGt+dxPLZ4NX4pyMjiP0yrw1gcF+V856H+FuMCt7u/AE+cvwxefK+...iahvMiVS5BtErat5YKlNepN1hBEo+DClfPbQlq4BN1g/mkzQqGTH7WrvLYLSh8n0a9rf6RbNi2Dlp4YmzFYiDwRE/B2mb4ew1Z48FJ/XBW80HwQvxJgk9V'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

>               ciphertext = encrypted_data[self._SALT_SIZE / 12 :]

                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:438: TypeError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002BB4320B770>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002BB425CA1B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-521/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002BB425CA1B0>

encrypted_payload = 'IzNgm/Sl2oyNS+UZKPhRCUpzziShqz7/lFn3cCDJpX1deHKoSggLEYLmyM1YOTa8SGt+dxPLZ4NX4pyMjiP0yrw1gcF+V856H+FuMCt7u/AE+cvwxefK+...iahvMiVS5BtErat5YKlNepN1hBEo+DClfPbQlq4BN1g/mkzQqGTH7WrvLYLSh8n0a9rf6RbNi2Dlp4YmzFYiDwRE/B2mb4ew1Z48FJ/XBW80HwQvxJgk9V'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE / 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.13s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt // nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for //: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e78ddca2bce196f33: unsupported operand type(s) for //: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E25DCE58B0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E25B183FB0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E25B183FB0>

payload = {'id': 'acdf4152-5857-42e2-b5ac-df06c0a08159', 'salt': 'Ja+Fr2diYhvJ04PHsJXtIw==', 'secret': 'unit-test-secret', 'timestamp': 1760725694, ...}

key = b'o\x97\xff\x94\x84\xb7\x8d\xfb\xa194\xf0`\xaf\xc3}x\xfb\xc0p.\xe7\xc0?B\xd6\xaeJ\xac\x80\t\x1f'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt // nonce + ciphertext

                    ^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E25DCE7A70>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E25B183FB0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1454/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E25B183FB0>

payload = {'id': '90c7e254-6916-4b48-8aab-3fa158b3d03f', 'salt': 'TFRInxsfUvluL7zLncTASw==', 'secret': 'unit-test-secret', 'timestamp': 1760725694, ...}

key = b'\xe8\x94\xb0\xe2\x06\x95\xdc\xcc\x1b\xc1brP\xc8P\xeed\x18\x0b\xb6A\x93\xb8\x8e\xc2t\xadC\xfd\x88\nb'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt // nonce + ciphertext

                    ^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001E25DD0D8B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpc_7izpt7.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E25B183FB0>

payload = {'id': '8ab10e7f-12ec-4239-b3af-3b5def85db07', 'salt': 'z+Ymky3HYbhu4pF/Pebe+g==', 'secret': 'test-secret', 'timestamp': 1760725695, ...}

key = b'\xa5@\xacW\x8d#\xc7d\xe7\xde\xb7\xfc\xd5c?ji\xea\xf5\x9bL\x15\x9a\xfc^\xc0\xa0\x1d\xaa\x02\xd6e'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt // nonce + ciphertext

                    ^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001E25DD0DA90>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp_bj2h60r.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E25B183FB0>

payload = {'id': '5191ca48-3289-46ed-b199-2b494a5836dc', 'salt': 'l60USr20SVi7S/onbQDXTQ==', 'secret': 'test-secret', 'timestamp': 1760725695, ...}

key = b'CS[\xb9\xdd\xb3\xba\x07C\xb2\xc0\xc7W\xba\xa4\x90\xd2\xa8!\rX\x15\x8b\x8b7\x8d\x9b`\xe1\xd9\x8d~'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt // nonce + ciphertext

                    ^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce // ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for //: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6b0188d9d89cd13e: unsupported operand type(s) for //: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001A2F1EC9670>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A2F0D53E90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A2F0D53E90>

payload = {'id': 'ba5e0d89-e423-407d-992f-b26a08cf8425', 'salt': '4XbhOvHncI7fI6C+UKjV0g==', 'secret': 'unit-test-secret', 'timestamp': 1760733729, ...}

key = b'\x12\xf0\xee\xf2\x8aq\xfbK\x11%\xf6\x9d\xa0\x9dP\xcb\xfc\x8f9\xc1\xb9_\x18\xdd\xa9\xe1\xca\xef\xaa0\x86`'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce // ciphertext

                           ^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001A2F1ECB860>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A2F0D53E90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1818/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A2F0D53E90>

payload = {'id': 'abc234c3-e302-48f9-be33-1b9e598d4dc5', 'salt': 'QDhoSC3tTOFyrkAvaNDrzQ==', 'secret': 'unit-test-secret', 'timestamp': 1760733729, ...}

key = b'\xc6\xbd&\x07\x84\xea\x96\n\xd4\xfcll\xff\x0c\x13\x13\x0c\x02_\x97\x1bT\x121k%\x0f\x93\xe4 \xa8\x90'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce // ciphertext

                           ^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001A2F1EF16A0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp88t5xyfj.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A2F0D53E90>

payload = {'id': '7dcb9b42-c78f-4c4b-bb64-53b2b10f36d5', 'salt': '6YE/C1Twvye15gCTT3PcnQ==', 'secret': 'test-secret', 'timestamp': 1760733730, ...}

key = b'S\x18\x9b\xa0\x89\xad\x8d\x03\xc4\x0e\x18\xfb_\x8e)\xcbc\xaf\xba\xba\xd4&\x0f_\xc9/$\xa1\x10\xf9\x8b\xfe'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce // ciphertext

                           ^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001A2F1EF1880>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpc4xs6tac.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A2F0D53E90>

payload = {'id': 'ca837aae-230d-44bc-8c8d-f3fa868d00a1', 'salt': 'CLnERL+3eq9YCv0vSTnm4Q==', 'secret': 'test-secret', 'timestamp': 1760733730, ...}

key = b"\x9a\x80\x95\x1ch\x90\xb4\x15lt>\xd8\x89\x9a3k|\x01i\xa1\xefA\x04\xa9\xb3\xfd',\xec\xad\xd5\xed"



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce // ciphertext

                           ^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.67s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT // 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start // fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE // 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.34s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE // 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C782CE21B0>

encrypted_payload = '4PdjUm7nRmamnxd1yfcV6JyaxRjZULU0fL5fsA5mXXTk48fI8p5MWXeSsRvgd2gBdjYYeLwUmv+od3YXMYG+vKZXzItthB9CVj7JIx6Mv/7FOPCClnByn...gyR2gwri+8JDUQDdTGfliYxolFB1HbSODFzWrQ2m0ddAj3VoRAClj0t7Oas1AgvIVO9b27DbwZU+Jlhl5sK0Www1l1j5bfCtbzJv3k2VgPFHG+89IL6F6r'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE // 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               ValueError: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:445: ValueError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C782E77AA0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C782CE21B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-830/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C782CE21B0>

encrypted_payload = '4PdjUm7nRmamnxd1yfcV6JyaxRjZULU0fL5fsA5mXXTk48fI8p5MWXeSsRvgd2gBdjYYeLwUmv+od3YXMYG+vKZXzItthB9CVj7JIx6Mv/7FOPCClnByn...gyR2gwri+8JDUQDdTGfliYxolFB1HbSODFzWrQ2m0ddAj3VoRAClj0t7Oas1AgvIVO9b27DbwZU+Jlhl5sK0Www1l1j5bfCtbzJv3k2VgPFHG+89IL6F6r'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE // 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE // 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C92E496E40>

encrypted_payload = 'TG5qqdS6gH9qE/i4BTLDc5RU72/fRI2uzjPN0l9suFNS3RaBlgdvuLCezSQPvr5SfIXquDPjSih0JfSqmyLAogPQs1qyGdLMYpprVhKbkFdiC8Ywe8Cuv...6nhhJcqFOJ50moZSMlLSxJr6OMlOmiEA8or0XVPifbYuxc2rvaLLBscrh8fS6f9EbN72KHDN7csql8e59WUzcWqmddfHr0owYX37A8mi6fNc9H3CmaIB46'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE // 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C930FF7950>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C92E496E40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-220/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C92E496E40>

encrypted_payload = 'TG5qqdS6gH9qE/i4BTLDc5RU72/fRI2uzjPN0l9suFNS3RaBlgdvuLCezSQPvr5SfIXquDPjSih0JfSqmyLAogPQs1qyGdLMYpprVhKbkFdiC8Ywe8Cuv...6nhhJcqFOJ50moZSMlLSxJr6OMlOmiEA8or0XVPifbYuxc2rvaLLBscrh8fS6f9EbN72KHDN7csql8e59WUzcWqmddfHr0owYX37A8mi6fNc9H3CmaIB46'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE // 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.33s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt % nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: not all arguments converted during bytes formatting

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e5b0ca4caa449527d: not all arguments converted during bytes formatting

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000110643F9460>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000011061841640>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000011061841640>

payload = {'id': 'b386a247-f69a-453c-93ca-00822fa4fb22', 'salt': 'FsNohTP3drS0yNk40bPATQ==', 'secret': 'unit-test-secret', 'timestamp': 1760695823, ...}

key = b'\x9d4\x9d}\x00/#^\xb6*r<\x10H\x990\x9e3\xdf\xads=\xf8\x83\xe8\xa9O\xd9\x9ax^\xb1'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt % nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: not all arguments converted during bytes formatting



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000110643FB8C0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000011061841640>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-107/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000011061841640>

payload = {'id': 'cfb1aabe-bfa7-486c-a320-f965cf10f750', 'salt': '+U2qn2ZOe9Jh9bT039eaJg==', 'secret': 'unit-test-secret', 'timestamp': 1760695823, ...}

key = b'\x00P\xe6\x0f:\xbc,\xbf\x81x$xD\x94\xaeD\xdb<\x19\x8f\x07\xdd\x8b\x95\x01\xfb\xebc$t\x8d\xcc'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt % nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: not all arguments converted during bytes formatting



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000011064421700>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpn31l2nav.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000011061841640>

payload = {'id': '6d9b9866-1d23-4e06-8104-e2b990de3e32', 'salt': 'LDXwvewhLjePWj5sg+jmuQ==', 'secret': 'test-secret', 'timestamp': 1760695824, ...}

key = b'+\x0f\xb9\xf1\xee\x8c\xc7\xc0\xb4&\xe3\xe4\xea\xe0\x93\xa5\xa5\xb3\xc7\xe3\x84\xf4e\xf6\xc8\xb5A#L|\x9d\xb9'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt % nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: not all arguments converted during bytes formatting



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000110644218E0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp108cy8um.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000011061841640>

payload = {'id': '6dbd2ece-9eb0-4c2b-8d0f-34eca002e49c', 'salt': 'tszneZcSZEhY0ZHVMqplJw==', 'secret': 'test-secret', 'timestamp': 1760695824, ...}

key = b"\xe3\xb0J\xa4\xbf\x15\xe2\xe5\xac\xce'U\xa2\xe7YF\xa9V\x90.>p\xe58\xa7\xbc\x1f\xae\xe7\x93\xe7s"



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt % nonce + ciphertext

                    ^^^^^^^^^^^^

E       TypeError: not all arguments converted during bytes formatting



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce % ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: not all arguments converted during bytes formatting

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef82999ab8b935de8: not all arguments converted during bytes formatting

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000183CF8C9610>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000183CD78E150>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000183CD78E150>

payload = {'id': '4beb2b36-9885-4a40-a0ee-0006fb6f1ce5', 'salt': 'VGfEI0F6Saown0H2u/Oi2Q==', 'secret': 'unit-test-secret', 'timestamp': 1760724664, ...}

key = b'\xa4\xf7\xd1\xb6\x91\xa4(\xd5>\t\xa1\x82U{]\xf5\xc2\xbb*\xf4\x15!\xc1\xfby\xcb|^\xd7\xf4\xc2q'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce % ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: not all arguments converted during bytes formatting



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000183CF8CB890>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000183CD78E150>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1407/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000183CD78E150>

payload = {'id': '1043b6c7-91dd-421a-b342-67aaf3dcd6e6', 'salt': 'rAiymS2T8mEnzdRNU0SZ6g==', 'secret': 'unit-test-secret', 'timestamp': 1760724664, ...}

key = b'\x0bC\xac\x15i:33J\xbb\xb3Zz+\x97<\xf4\x85\xbcaBk\xe0\x8c4M\x04\xb9z\xf7\x0b\xee'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce % ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: not all arguments converted during bytes formatting



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000183CF8F16D0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpl55s983a.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000183CD78E150>

payload = {'id': '13fe2fb7-7493-4d6c-9e84-4187f4a0334c', 'salt': '3fmu6yYqsUD11PZNy0r/lw==', 'secret': 'test-secret', 'timestamp': 1760724665, ...}

key = b'\xe4\x87H\x90\xac\xf9$\xdd$\x1c+\x85o\x052\xe2r\x87A\xc2\xb1\x0b\x95\x05\x89`\xf63=\xb9F_'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce % ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: not all arguments converted during bytes formatting



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000183CF8F18B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpvwea6oly.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000183CD78E150>

payload = {'id': '699e3ae7-c321-4123-a3a4-b3424423608e', 'salt': 'HQe0Yppl79nN4L/lCN8IZw==', 'secret': 'test-secret', 'timestamp': 1760724665, ...}

key = b'y\xd6=\xb5\x0c\x82\x16\x1b\xd3\xe7\t\xa1\x8d\x12\xb3w\xd6}\xf8<\xa8~P\xed\x99(\x1a\xe8\x10J=1'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce % ciphertext

                           ^^^^^^^^^^^^^^^^^^

E       TypeError: not all arguments converted during bytes formatting



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT % 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start % fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE % 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE % 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000260F8241880>

encrypted_payload = 'sPovFUqD27v8kFt5gb5tC3lbMLl7XHaK4y5RsV2U8DgsddsCqID5xL7zJuzeJ7Zxp/xVtU7BixE7ROTqMjnBmKarAol3qc9Mn2LOB6rnKOa3Vlf/6+ivO.../tmNoaAnkYaIHt682u/LjiS+7IWYN2ZBLotp1mfvlzp/uGru54LAmhhIhkpHnijnzUXpwC+btgeU67zBn6qwf5HlXFoLMx2fTHILCF94wgKUPglpMqHYlj'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE % 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               ValueError: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:445: ValueError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000260FAEBB8C0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000260F8241880>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1511/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000260F8241880>

encrypted_payload = 'sPovFUqD27v8kFt5gb5tC3lbMLl7XHaK4y5RsV2U8DgsddsCqID5xL7zJuzeJ7Zxp/xVtU7BixE7ROTqMjnBmKarAol3qc9Mn2LOB6rnKOa3Vlf/6+ivO.../tmNoaAnkYaIHt682u/LjiS+7IWYN2ZBLotp1mfvlzp/uGru54LAmhhIhkpHnijnzUXpwC+btgeU67zBn6qwf5HlXFoLMx2fTHILCF94wgKUPglpMqHYlj'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE % 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.17s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE % 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001AC4E7C38F0>

encrypted_payload = 'Zf6Rthv/rt4mo2JxwYh3UXkZpZk5DdyWBy/eg416v8l64txw/bI+eq3t2dkQl9qn9ybSdgOQ/9cjH9xe/wvKsNuc1HnWolQnLjw85QlP9LwXOfGMwwGeR...Q4Io6pSvc0zQAgZ8kjHFwM8YdgMNck5DY1IRA8ICVgVD0Dv5W0XzzcU6L3LtNPpJOOiJhNWEPrMCtXH//owub8owWRJ/0YcZXLhkz6eIosqkM3DqI/QRfg'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE % 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001AC512EB8F0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001AC4E7C38F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-922/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001AC4E7C38F0>

encrypted_payload = 'Zf6Rthv/rt4mo2JxwYh3UXkZpZk5DdyWBy/eg416v8l64txw/bI+eq3t2dkQl9qn9ybSdgOQ/9cjH9xe/wvKsNuc1HnWolQnLjw85QlP9LwXOfGMwwGeR...Q4Io6pSvc0zQAgZ8kjHFwM8YdgMNck5DY1IRA8ICVgVD0Dv5W0XzzcU6L3LtNPpJOOiJhNWEPrMCtXH//owub8owWRJ/0YcZXLhkz6eIosqkM3DqI/QRfg'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE % 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt ** nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e227a69968d1c2ea9: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000020F432391C0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020F4059F050>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020F4059F050>

payload = {'id': '709c4751-3abb-4d13-b484-1dec97bf8d3b', 'salt': 'BJecz8dzF6uVqSMvwlZq+A==', 'secret': 'unit-test-secret', 'timestamp': 1760733447, ...}

key = b'\xd9\xc9Vr\x7f\x8c\x97Y\xb3\x9d\xb0\xdf\x99\r\x89\xdb\x1a\xe8&SmZ\xbd\xf5\xb3\x92\xe4a\xff\xe7\xdc\xe9'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt ** nonce + ciphertext

                    ^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000020F4323B5F0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020F4059F050>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1805/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020F4059F050>

payload = {'id': 'f9b5bf4b-574e-4adb-af11-5f88e84ad196', 'salt': 'kUQH14+qFt7fD3yT3hhPHg==', 'secret': 'unit-test-secret', 'timestamp': 1760733448, ...}

key = b'\xe3!:\xef\x08u\xf1Q)\xfd\xe5(\x166\xec\x1dR$\x8dv\xed\x90\x8e\x0et\xa9N\xf1\x0e\xa6\xd8\xb4'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt ** nonce + ciphertext

                    ^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000020F43261400>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpi40n4yub.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020F4059F050>

payload = {'id': 'd7f059f6-64c4-42c8-87be-7bf74601dc0b', 'salt': '3HBO4TNjV+GlfeO4bzKvIg==', 'secret': 'test-secret', 'timestamp': 1760733448, ...}

key = b'W\xe6\x86mC7Q\x97\x94t\x07\xe9\x9f\x16\x9eB#\xabv\x1d:6\xa3\x16o\xc1\x83\xd7\xdb\xa5\x9d\xd5'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt ** nonce + ciphertext

                    ^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000020F432615E0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpih_nz7yz.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020F4059F050>

payload = {'id': '739aba0a-585b-4d4c-a567-ec5acf64c357', 'salt': 'lP9VumrkiQU8WcJkoDiWlA==', 'secret': 'test-secret', 'timestamp': 1760733448, ...}

key = b'\xe5Q(\x9e*f\xfb\xce\xd8$\xd237zn%(\x96\xd5\x9b\xf3\xba:w\x00*N\xae\xc9\x9d:\x02'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt ** nonce + ciphertext

                    ^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.59s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce ** ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e913c9faf5293f30c: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000015E8C849280>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000015E89C558E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000015E89C558E0>

payload = {'id': '5ca21c8d-6ed4-463e-9a5a-30e772e72c76', 'salt': 'Ng/2GOWg03tqlbVQqMhvcg==', 'secret': 'unit-test-secret', 'timestamp': 1760714061, ...}

key = b'\xf6-\xaej\x8cr\xea\xc3\rZS\xda\xbf\xaaD\x18\nS\xb9\xb009\x1fd\xc0\xcf8 \xc7\x93\xf2-'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce ** ciphertext

                           ^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000015E8C84B680>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000015E89C558E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-931/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000015E89C558E0>

payload = {'id': '0e49864d-9189-4f4c-b42c-b469cfb2d155', 'salt': 'n9LBG2XUym/anlew5g9hnA==', 'secret': 'unit-test-secret', 'timestamp': 1760714062, ...}

key = b'\xe7\xa9\xd7\xd0\x1b\x9c#\xc4n\xf0"\xa6o\x88\x883\xcd\xcaI\xefS\xdb|\xc20oCx\x9b\xba8"'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce ** ciphertext

                           ^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000015E8C871490>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpskexq8_n.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000015E89C558E0>

payload = {'id': '4d961a5e-342c-4c80-b9cf-be0626162add', 'salt': 'T50cpwyCEiVURECdp6yXxQ==', 'secret': 'test-secret', 'timestamp': 1760714062, ...}

key = b'Lx\xcfbA\x18\x00\x02\xbfyN5w\xe7jL;+\xc1Q\xb0a\x82\xc8\xc9\x82\x81V\r\xb9\xb7\xff'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce ** ciphertext

                           ^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000015E8C871670>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpd7_xgbvs.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000015E89C558E0>

payload = {'id': '70336171-6c7e-4600-9e32-a247e3216e64', 'salt': 'b5EJcHcBKuwmbZucgrACIA==', 'secret': 'test-secret', 'timestamp': 1760714062, ...}

key = b'f<!\xa4\x8c?\xdf\x97\xc4\x9f\x9f \xc8\x132p\x84\x82\x01\xa2\r+\xea\xf5c\xfd\x9b\xfdT\x87\x90\xfd'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce ** ciphertext

                           ^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT ** 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start ** fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE ** 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.FFFFFFF.FFF.........F....................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195217585029Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195218486925Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000017A880F78F0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017A87F621B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1687/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017A87F621B0>

encrypted_payload = '7CQu6yM7a85IY4fMeiuTPksrbbOP5gwHqp1/YOa0cq31QD9a0h70rk1lcbiS1k/ivt5MIjQdgAhaugb+AUOXEsAUCQxn3VNIjQ69bF2CrbeIJbe9DdrYA...RhAyDGb6QYlJ3F9DxLnl+J9s2p1YS1A2JkGMgabWc0c+r6vvNK2ynDHWBwjeFqkbCrbQPjGq1cq4bWT/mpWPx7vZKg4ZWFwgkJFjLh/gZ0BuIEPTYc+Slp'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE ** 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

11 failed, 31 passed, 23 warnings in 20.63s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE ** 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026C17D21BB0>

encrypted_payload = 'wEQKeSGiaRhDj8Y9nOvgm2cFyZf+pnvY6xGAaBLlO5ysU+YeTI5wv9ub4CMeWaIDPUCxeXtfiDFgY3oAlu/17qNdTB2oqETsWJo/X6TlSMFYlmMKXm+aM...db3Mqsc7zpeI8QSEyN9LJ7d0RBZd4eL87RZU749l1rm+0UWkBjym14+DI5PCBp1g7UM5kq373urJYp/8n9PnsfEzNsUjMWtPS72jWIMejMlcF3/bki+U2N'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE ** 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               ValueError: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:445: ValueError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026C1A98B6E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026C17D21BB0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1341/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026C17D21BB0>

encrypted_payload = 'wEQKeSGiaRhDj8Y9nOvgm2cFyZf+pnvY6xGAaBLlO5ysU+YeTI5wv9ub4CMeWaIDPUCxeXtfiDFgY3oAlu/17qNdTB2oqETsWJo/X6TlSMFYlmMKXm+aM...db3Mqsc7zpeI8QSEyN9LJ7d0RBZd4eL87RZU749l1rm+0UWkBjym14+DI5PCBp1g7UM5kq373urJYp/8n9PnsfEzNsUjMWtPS72jWIMejMlcF3/bki+U2N'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE ** 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE ** 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021DEDA021B0>

encrypted_payload = 'vZNVju/QfzqF1Mt1oDaV7roqF+EceLPV1wZuPrgafETVMfswyFHsFzA+gB0b7xoFiDzVhopWUcIYlGty2aYeCmz4l+PU4LhzvQQWH+5jdMGrDs8SVLGGc...daCEQ0pGj4F00mqVLlXGNLtoX13KgOVD4YmXlcbYN3wUUrfLSAQRG2aWyzg+i946SzIShfXApgo1R6l1NVfzQ7xr7QPnSNIRGeKrWWfC+fHWLE51G6GY/J'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE ** 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000021DEDB97920>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021DEDA021B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1795/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021DEDA021B0>

encrypted_payload = 'vZNVju/QfzqF1Mt1oDaV7roqF+EceLPV1wZuPrgafETVMfswyFHsFzA+gB0b7xoFiDzVhopWUcIYlGty2aYeCmz4l+PU4LhzvQQWH+5jdMGrDs8SVLGGc...daCEQ0pGj4F00mqVLlXGNLtoX13KgOVD4YmXlcbYN3wUUrfLSAQRG2aWyzg+i946SzIShfXApgo1R6l1NVfzQ7xr7QPnSNIRGeKrWWfC+fHWLE51G6GY/J'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE ** 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.26s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt >> nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for >>: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ebae0649552375f6c: unsupported operand type(s) for >>: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000228D4DE5700>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000228D4C6A1B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000228D4C6A1B0>

payload = {'id': '6df7be91-36c3-4744-8fbf-00f7b0eac74b', 'salt': '8jnuVcA5l82QHyuiFz6i1w==', 'secret': 'unit-test-secret', 'timestamp': 1760713253, ...}

key = b'\xe8\x91$a%jrhWY{A#\xb7{\xa3\xdf>\x98\xcb\xae\xa7\x1e\xd6\xc3\x03E\x0f2\xc6\tq'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt >> nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000228D4DE7A10>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000228D4C6A1B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-893/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000228D4C6A1B0>

payload = {'id': '2505eb58-9536-474e-ba0a-0df754cf4000', 'salt': '6NPL9UllqiHMEimyZi8U6Q==', 'secret': 'unit-test-secret', 'timestamp': 1760713253, ...}

key = b'\xdc\x05\xc7M\xc5\x0e\xc9Z\xce\xe8\xcb\x1f\xe5/m\x0c\x0f\xd0@\xc3\xfa\xdc\xc1\x11IN\xf0~\x847\xabO'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt >> nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000228D4E0D820>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp44byez2k.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000228D4C6A1B0>

payload = {'id': '7b3997ab-1cc1-4b6e-93f4-10b471c13381', 'salt': 'zAaa4PvsyUjg3v8A2ZIRDw==', 'secret': 'test-secret', 'timestamp': 1760713253, ...}

key = b'=1\xc6\xee\xed%\x10\xb1\x9f\xb8\xe8\x7f\xe2\xebmYz2N\xba\x9d\x15\xfa\xear\x05 5?&%\xe2'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt >> nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000228D4E0DA00>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmppmzgkps1.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000228D4C6A1B0>

payload = {'id': 'a97067ea-3394-499b-84ff-3b7833613dfe', 'salt': 'USlNBh3c6yFwnxd8+t8ESg==', 'secret': 'test-secret', 'timestamp': 1760713253, ...}

key = b'\x13\x11X\x9e\xa7\xb5\xb7D8EKi\xec+*w\x11\x9d\xe6\x88\xa5\x17\xd4\r\x99\x15\x96,\xdci\x19m'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt >> nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.68s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce >> ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for >>: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef2a2715d6685f8c7: unsupported operand type(s) for >>: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026599F057C0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026599D721B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026599D721B0>

payload = {'id': 'cc766d23-22d7-462d-b3d5-3a06778606ca', 'salt': 'j9t/z/4FnT4U4pHk21hHkw==', 'secret': 'unit-test-secret', 'timestamp': 1760725672, ...}

key = b'\xec+0\xb0\xb1$l\xa8\x93\xfbA\xad\x81[\x81q\xf8\x81\xea\xab\xbc~mK\xe0\x87K)=\xa9\x10\xc0'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce >> ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026599F07B00>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026599D721B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1453/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026599D721B0>

payload = {'id': '8bd67f7f-0ce4-40f1-91ac-e5e20f1d8516', 'salt': 'tRSCI/ljPbSqabJHpfutlQ==', 'secret': 'unit-test-secret', 'timestamp': 1760725673, ...}

key = b'\x93\x06S\xa2\xe9\x8d,\xa0\xbe-\xefJ<\x87\xa8\x13\xf7\xfc\x17\xb0\xd7\xfd\xb1\xa4\x81\xc5\x1c\x8c\x054\x12\xe7'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce >> ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000026599F29910>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpse61y2_4.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026599D721B0>

payload = {'id': 'd32d896d-2bdd-4524-ad97-39aa7bf3ded8', 'salt': '5LRqi0lF1/bD8hm2I9ST4w==', 'secret': 'test-secret', 'timestamp': 1760725673, ...}

key = b'\x8f\x9a\x1f\x94Y\x06C\x01\xfa\xad(\xf4\x80\x8d\x85L\xe6S\xae\xf6\xe5\xc7=\xb0\xd0\xeb\x1bxb\xc4-\\'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce >> ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000026599F29AF0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpyovj9mv_.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026599D721B0>

payload = {'id': '3442af69-a568-497b-8b1d-6cbc803e12dc', 'salt': '1qg6gtCRi5BOu3xXMaMC3Q==', 'secret': 'test-secret', 'timestamp': 1760725673, ...}

key = b"\xc8\x03\xac6'\xcb\x86DB\x93Mdsz4'\x9d\x06.\x83\xa7qY\xe1\x80\xf7\x9a\x15\x85G\x9e("



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce >> ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.72s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT >> 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start >> fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE >> 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE >> 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000015921715850>

encrypted_payload = 'ExIDF4DOUWNYMtHMOZjw9FN3sEEBnoQ5+v3y8UhQsg5f3RAtwbrIYajKjmT5W+nLukkm3RvT7aQGjJPL6+SHInH5sNl3P1nVZDjUnXdfA7OALD4kYhd9C...2/J9MclZRIaGvyCNQjGiKFmEhhY99keB9MziYazhdAem7MAQpVeCQRuoMM9a4R1UcMxJ9NxTIqgb27NHAqahJtnRp72+2I3ek/SCVIVNNAxiV7R6p9Gd5a'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE >> 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               ValueError: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:445: ValueError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001592430B530>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000015921715850>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-420/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000015921715850>

encrypted_payload = 'ExIDF4DOUWNYMtHMOZjw9FN3sEEBnoQ5+v3y8UhQsg5f3RAtwbrIYajKjmT5W+nLukkm3RvT7aQGjJPL6+SHInH5sNl3P1nVZDjUnXdfA7OALD4kYhd9C...2/J9MclZRIaGvyCNQjGiKFmEhhY99keB9MziYazhdAem7MAQpVeCQRuoMM9a4R1UcMxJ9NxTIqgb27NHAqahJtnRp72+2I3ek/SCVIVNNAxiV7R6p9Gd5a'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE >> 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE >> 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001CECDC52120>

encrypted_payload = 'kFKBIu4jzqjKm6c9Rk3WPM0EKQfye0gb/8fL+C31cyoKpAhjJXxOSqmrRW17MR6CHmsCfGaLDnK0QMLz+UnKnk0fDSN14bsKvscv+VuPNvTyJQ9bwPyFO...A1gjm9vjKepqyBUJc8xD2eCzs7xkA3cq+nwOStSkz6sOIm7kpcdiwl73luF4Fc9vhJ3dywwGkzvWVxcxaDqynzf27T6RhrgU9iIl9sR2tOL4x1Wk3tvzoE'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE >> 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001CED08BB920>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001CECDC52120>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1560/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001CECDC52120>

encrypted_payload = 'kFKBIu4jzqjKm6c9Rk3WPM0EKQfye0gb/8fL+C31cyoKpAhjJXxOSqmrRW17MR6CHmsCfGaLDnK0QMLz+UnKnk0fDSN14bsKvscv+VuPNvTyJQ9bwPyFO...A1gjm9vjKepqyBUJc8xD2eCzs7xkA3cq+nwOStSkz6sOIm7kpcdiwl73luF4Fc9vhJ3dywwGkzvWVxcxaDqynzf27T6RhrgU9iIl9sR2tOL4x1Wk3tvzoE'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE >> 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.16s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt << nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for <<: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e82c24a40f195b5fc: unsupported operand type(s) for <<: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000020B399455B0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020B397CA1B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020B397CA1B0>

payload = {'id': '61476292-db23-4804-87aa-b672aa80919b', 'salt': 'EmR/qTYG3oZ59ZEzG+CmMg==', 'secret': 'unit-test-secret', 'timestamp': 1760747347, ...}

key = b'z\xd2\x16\xb1Z\xe5\x19\xfb-\xcfo\x87\xeaZ{\xff\x1b\x80;H\xc3qZ{]9/\x7f!\xb2\n/'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt << nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000020B399479E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020B397CA1B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2430/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020B397CA1B0>

payload = {'id': '6ed7db32-8aeb-4d1b-b1b3-8c8d1f07d638', 'salt': 'Rmr/vZsGZYG+b4z81zR6jg==', 'secret': 'unit-test-secret', 'timestamp': 1760747347, ...}

key = b'\x10\x01*x\x053* \x94\x15`\xf9o\xf9{\x16i\xd1pl\x9aS8\xdd\x9e\x89\x8dSO>\xb9\xa6'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt << nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000020B3996D7C0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp01cp8ij0.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020B397CA1B0>

payload = {'id': '80495632-d7b2-475a-97bc-72d4c8f40a0f', 'salt': '7Cq+aHFvw5cV6UGUQM5/6A==', 'secret': 'test-secret', 'timestamp': 1760747348, ...}

key = b'+?\x0b\x99\x1d\xe4\xd0\x14\xbb\xce\xa2\x9a\xdd\x84>\xce\xb0\xc8\x1d6V9\x04\xa4\xeey\xc2\x90\x16V\xecL'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt << nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000020B3996D9A0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpbozz2u7n.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000020B397CA1B0>

payload = {'id': '7562051c-5f13-40ac-89b0-bc692b3f5181', 'salt': 'oNrb+ZPK2Pk/cP4tR3zgUg==', 'secret': 'test-secret', 'timestamp': 1760747348, ...}

key = b'\xc4Q\x8f\xd0\x9aj\x10\xbf\xe5r\x03r\xf2\xd6\xbf\x13\x06\xb7A\xa0w\xbf\x11\xc0\xe1\x1f5\x94\x97Y\xbfq'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt << nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 21.50s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce << ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for <<: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6ace21cfe5425442: unsupported operand type(s) for <<: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002AF881895B0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002AF8566E510>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002AF8566E510>

payload = {'id': 'b63c3e60-598f-4013-80e9-7d47ad0bf54c', 'salt': 'BAOcNv0gTvz8J6nI0YkCXA==', 'secret': 'unit-test-secret', 'timestamp': 1760704143, ...}

key = b'2\x01\xadA\x10\xf1\t\xe9\x93v;u\x95boD\xbf\x92i\x9e\xb0\xbb?\x9e/@\xc7\x03W\xc2,\xc7'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce << ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002AF8818B740>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002AF8566E510>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-477/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002AF8566E510>

payload = {'id': '8cb045e6-be62-4fc4-ad1b-09c0954a03d7', 'salt': '0zbIBOSWIRUwDu46qPjK4g==', 'secret': 'unit-test-secret', 'timestamp': 1760704143, ...}

key = b'\xd9+\x0b\xa9l\xcaq\x94\tM]\x9f`I\x16\xb4\x84\x8f3\xfa!Q\xf4P\x9d[B\x05\x81"\x88\x03'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce << ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002AF881B1550>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp9kh6aid_.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002AF8566E510>

payload = {'id': 'fb23e727-2e32-49a8-879f-79c788dd5b42', 'salt': 'pqrhsnB+dHUZor6W6TKQvw==', 'secret': 'test-secret', 'timestamp': 1760704143, ...}

key = b'\xd8t\x9fG}\x877\xf2[\x08\x14\xed\xd6G2\xdc\x90f*\xcfS\xf1\xc6A\xf6\xb0\xa2\xf3Q\x92\xec\xaf'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce << ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002AF881B1730>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp37xkx39q.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002AF8566E510>

payload = {'id': '82a53203-20f3-47f2-a4ad-4d56320cc759', 'salt': '6QCJ/TjRfutRRh4JHBlGMA==', 'secret': 'test-secret', 'timestamp': 1760704143, ...}

key = b'{\x96\xb4 d\x19a\xe1\xb4\x93D\x1c@q\x87\x8e$Fm\xd5@0\x92\xec9LE\xb4\xf0\xaaP\x80'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce << ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 21.67s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT << 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start << fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.27s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE << 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000200FCF1B620>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000200F9EB6FC0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-772/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000200F9EB6FC0>

encrypted_payload = 'OBldh1nfAG6DsWoQhhFAVRwb/BRUHe8WfMnw9PqTBaX2qjtXgGKXpVTjcqon0KTPRGAuWz0jwcnxm+FdOSlT6gyF4dvgNRLd3pQznvRYPBoy/k9Atse1F...jig1lyt51o5NpTXDY70B/MoqUNfB51dSL37/CfbgfInC0DERHAtqiaqrWjJ4e7Z5S1xG75gUU2Fy05Z+WY5FUPbAfwdDq/TYCzN8imtFLFhoiLDvX5+0m/'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE << 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE << 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002683EE3A240>

encrypted_payload = 'qXNdQqzDXCOQhk6eaMTt921gmAU8gFTm9jpAthiQoXyyZgiHHkipZ5aNxCY2kzPWML7cpAvlxZX7lmHmx2fWzKR5j+cj7zTE9U5twlhscUijYsiVihkaV...UY7VN0pSKwIGSBtKR+dFIeyNevKupEFIvnE17W6BaO05VUVlEhLl8EXHh/c7iCCEXngdwH2SHx4KOFPds4brDtVoicjEXKaMPwUFLs+AAn/m9XFyrt4hwQ'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE << 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               ValueError: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:445: ValueError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002684193B4A0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002683EE3A240>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-676/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002683EE3A240>

encrypted_payload = 'qXNdQqzDXCOQhk6eaMTt921gmAU8gFTm9jpAthiQoXyyZgiHHkipZ5aNxCY2kzPWML7cpAvlxZX7lmHmx2fWzKR5j+cj7zTE9U5twlhscUijYsiVihkaV...UY7VN0pSKwIGSBtKR+dFIeyNevKupEFIvnE17W6BaO05VUVlEhLl8EXHh/c7iCCEXngdwH2SHx4KOFPds4brDtVoicjEXKaMPwUFLs+AAn/m9XFyrt4hwQ'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE << 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.23s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE << 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.FFFFFFF.FFF.........F....................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T154513597784Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T154514562070Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EE76949820>

encrypted_payload = 'xrqLbwM0w4tyJtsAbPlOHy0cCFQviWMHJ3GrCFkehKJspbRByfM4gVvURhp4u5HhKIE2TWiHSwvklrSHKg4vmZlOR5bpZR9p9uPCS2bND7GeHJ25pt4X6...e6psTlhBbQeprE2XrYc2Bq5WVvrBUrU1anMiZb40Tf8OX2/bHM2AHC/yesDLQlKdZOn7cVi3AlMFNXIiztsqhq1F6mmlwaQJ5mASRMg4siY2XrYSTkANi8'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE << 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001EE795EB800>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EE76949820>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1014/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EE76949820>

encrypted_payload = 'xrqLbwM0w4tyJtsAbPlOHy0cCFQviWMHJ3GrCFkehKJspbRByfM4gVvURhp4u5HhKIE2TWiHSwvklrSHKg4vmZlOR5bpZR9p9uPCS2bND7GeHJ25pt4X6...e6psTlhBbQeprE2XrYc2Bq5WVvrBUrU1anMiZb40Tf8OX2/bHM2AHC/yesDLQlKdZOn7cVi3AlMFNXIiztsqhq1F6mmlwaQJ5mASRMg4siY2XrYSTkANi8'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE << 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

11 failed, 31 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt | nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for |: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec3bf713e25e585db: unsupported operand type(s) for |: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F661FA5910>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F65F5EDFD0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F65F5EDFD0>

payload = {'id': 'c1a022fd-a682-4363-9e3e-357c89d2902c', 'salt': 'Za+uyV+ouHZETLH67dOi7g==', 'secret': 'unit-test-secret', 'timestamp': 1760726157, ...}

key = b'\xd62\x8d\x19\xd3b\xe1\x972\xa0\t\xd4\x92jQ\xe48OR>F\xe0\x1b\x85\x19\xfcU/@\xfew\xf7'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt | nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F661FA7A10>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F65F5EDFD0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1475/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F65F5EDFD0>

payload = {'id': '8738d30e-53d7-430d-9466-65a3dd7e8942', 'salt': '5PvKKrAkJAglEHMzqQxbeQ==', 'secret': 'unit-test-secret', 'timestamp': 1760726157, ...}

key = b';\xa3J\x83\xa2)\x1fQ\xfd\x86\xf4\xe11\x17n\x10(R\x1d\xa6)\x82\xc4;t\x8ep\xcd\xcaIZ\x19'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt | nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F661FCD850>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpou4cej6u.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F65F5EDFD0>

payload = {'id': 'aa132b89-9a35-49f6-a6ec-1f91336b3975', 'salt': 'Eu1jt/JdcMhxOdMEJKffKw==', 'secret': 'test-secret', 'timestamp': 1760726157, ...}

key = b'\x05_\x85\xe1e5;bD\xce\x17+\xd5T|>\x9d\x84\xa82\x82\x89\xb8\xe0\xf4\xd2\xbd#\xa3\xae\xa6\x01'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt | nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F661FCDA30>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpkhemurpr.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F65F5EDFD0>

payload = {'id': '6f390fd4-8e7f-4664-a937-4fadac6d4bdf', 'salt': 'tPQ8abgdw8SG3mTpbFxogg==', 'secret': 'test-secret', 'timestamp': 1760726158, ...}

key = b"\x1a\xca\xa8\xc9\x86RFF\xf0\xef\xc8^\xe6\xb3\xc7'\xaf\x93ZU\x11Ut\x14\x05\xe9J\x0f\x1aY\xdbe"



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt | nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce | ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for |: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e7c96ea7f1f7f3365: unsupported operand type(s) for |: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B44E0456A0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B44B51A780>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B44B51A780>

payload = {'id': '05e2199f-1d32-4261-8668-6f0760c6f2fc', 'salt': 'xgwI8i51yCFyyPzcbY8Paw==', 'secret': 'unit-test-secret', 'timestamp': 1760726091, ...}

key = b'1\xfa\x8f\x8aYN\x18]#\xa7\xbf>\xac\xdf\x89\x0f }kM#\xe0@\x85\xd6\xd4\x1e$\xd0}\x07\xe3'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce | ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B44E047920>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B44B51A780>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1472/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B44B51A780>

payload = {'id': '4d8ae092-6afe-452e-aea0-e10e55e4e81d', 'salt': 'okyTFSe2Ufi5c5z1iNHIRg==', 'secret': 'unit-test-secret', 'timestamp': 1760726091, ...}

key = b"%\xe2{\xfe\xda\xa4,Z\x01Z\x1a\x91\xfd\x13l\xe1\xbe'1\x93\x0bT\xb0WM\xfb\x0c<[\x7fm\xd0"



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce | ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001B44E071760>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmptvktmg_h.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B44B51A780>

payload = {'id': '76c77d86-fc4f-471d-b66a-9db6e41e865f', 'salt': 'lbdg0fZmj3ygTmTdDXzr8Q==', 'secret': 'test-secret', 'timestamp': 1760726092, ...}

key = b'(T\xe3\xdf\x92}\xbbk\xa90\xdf\xfd\xe5S\r\xb8\xa85m\x90\xa2\x06\x89\x1e}\x06~\xde\x06x\x13\\'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce | ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001B44E071940>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpcfckrvw3.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B44B51A780>

payload = {'id': 'e8ac1240-32ab-41c3-9c1b-de928242369d', 'salt': '49nCWHaFMxaYSc6WBqRahQ==', 'secret': 'test-secret', 'timestamp': 1760726092, ...}

key = b'k\xad\x80\xafb\xc3[F\xfd\xd1\xe8Q\xb7\x1f/\xea\xfb\x80J\xb8\x05\xd3\xd0AmO\x87\x95\xd5\xd1\x18\x16'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce | ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT | 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start | fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE | 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE | 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE | 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt & nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for &: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb8fd03ee1f05b5cd: unsupported operand type(s) for &: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000212817B57F0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002128066DF40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002128066DF40>

payload = {'id': '69e3c3ca-5631-48a0-bb37-1943632105a7', 'salt': 'oSIJmDvHuMEVnl1/57C9cQ==', 'secret': 'unit-test-secret', 'timestamp': 1760734202, ...}

key = b'c\x1b17\x17\xac\xb6\xa3ap\xb6\x14\x839\xf5\x83\xfa\xdc#\x9a5\x933\xc3\x92\xe5\x8aI\xe2r\xf7\xea'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt & nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000212817B79B0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002128066DF40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1840/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002128066DF40>

payload = {'id': 'f82c0847-ee65-44c4-b887-fde2455c2b62', 'salt': 'TtanzICMMyIQx16fUnUlng==', 'secret': 'unit-test-secret', 'timestamp': 1760734202, ...}

key = b'\x88\x9c\xcd\xd0\x9c\x1c\x90\xef\x91\xd3,?3\x0c\xd6\xdc\x98\xdb\xa8\xd6)wk\xe2|\xd8A\x065\t\xe5\xe6'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt & nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000212817DD7F0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmps_0eu_5c.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002128066DF40>

payload = {'id': 'c844d0c2-0b8b-4404-8e88-57cb3772df74', 'salt': 'i11FRIV4n5dOpu6GqM20Qg==', 'secret': 'test-secret', 'timestamp': 1760734203, ...}

key = b'\xc9\xb9iJ$\xeaA]\xde\xde/\xca\xb6>\xc4>\xcc\t\xde\xbc*\xc0\x04\xc9\xee:\xd7\xa8\x12\xd3\x01\x11'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt & nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000212817DD9D0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp319r1sup.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002128066DF40>

payload = {'id': 'c50de514-ce1f-4b16-9b72-1703f3e8a933', 'salt': 'w1ndBHPhXsiccf3Gp9tw+g==', 'secret': 'test-secret', 'timestamp': 1760734203, ...}

key = b'\xf6\xe5\xb8\xaei?p\x05\x04=\x14a\x1f\x90\xa1\xedz*\x0b\xda\x19\xff\xc2\xff\x99\xd5P\x8e\xce\xba\xc7\xf3'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt & nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce & ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for &: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eb667c113fc047320: unsupported operand type(s) for &: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F261E895B0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F261CF21B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F261CF21B0>

payload = {'id': 'f6a26f97-cbe4-47d0-aa5e-b5f10f529c3d', 'salt': 'P6vLRygxNlDXAi+FuwFnzQ==', 'secret': 'unit-test-secret', 'timestamp': 1760720423, ...}

key = b'\x8f*\xf15\xf5+Bw\x03\xdb\x0egw*)\xb0\xbd\x1d\x16P\xb1\x19Y\x98\x90\xfbb\xbaK\xfb\x8a\xaa'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce & ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F261E8B8C0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F261CF21B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1217/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F261CF21B0>

payload = {'id': 'faae92e5-3f36-4db1-89a3-b4b407ea3d7c', 'salt': 'n7ml2/zM9zZEKdovtn7jnA==', 'secret': 'unit-test-secret', 'timestamp': 1760720423, ...}

key = b'\x05\x868\x9au\xd9\x93\t"\x95\x1b\xbdo1s\xf7\x15s\xe7\x12\x1eo\x17\xd5\x80\xa3\x02\xfd\x96w\xd5\x8f'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce & ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F261EB1700>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmppwvtb7ec.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F261CF21B0>

payload = {'id': 'bed23623-72d8-470b-a727-1067e1ad8001', 'salt': 'iV3XVDwuLROpefC9H1YJdQ==', 'secret': 'test-secret', 'timestamp': 1760720423, ...}

key = b'\xeeZ\x00\x14\\\x0e\x87.z\xf8!\x13\x12t\xb3\x13^\xd8lWtl8\x84I[\x04\x9af*n\xf2'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce & ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F261EB18E0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp3n68w4k2.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F261CF21B0>

payload = {'id': 'a51ad0a3-9d01-4522-992a-b256f6865c87', 'salt': 'lHM1u1NOb5HAsi3G6vJu5A==', 'secret': 'test-secret', 'timestamp': 1760720424, ...}

key = b'\xea6\r0\x96\x94\xbf08\x9b\xc7\xda_y;\x9e\x9e\xc0\xb1%/\xe8z\xe7\x04\xb8\r\xb1\xa2\xbaY\x87'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce & ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT & 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start & fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE & 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE & 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022F2CA7BAD0>

encrypted_payload = 'Cd5vRAtkXprjMquYQIFtAkdKpo6b1P+WD+NfSKXKWlJvFdPC9irSjxaV6whnAHTn/ghMybaIImHoqF+wdmChd5Cd1GZjvj8vPd0MfSPKZuU3/gz+EcFea...Q47SWKsETB0qdkhkpviDOnCWT1bmwL9YWUCcTQfwsRumE4kA/ARV/9Np8L9U38w0Y/0xZh+V3/gLZnrCRLzI3pws1pRgvrlv6SCnkLtA42nDhg87ygsw8c'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE & 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               ValueError: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:445: ValueError



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022F2F5A78F0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022F2CA7BAD0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-292/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022F2CA7BAD0>

encrypted_payload = 'Cd5vRAtkXprjMquYQIFtAkdKpo6b1P+WD+NfSKXKWlJvFdPC9irSjxaV6whnAHTn/ghMybaIImHoqF+wdmChd5Cd1GZjvj8vPd0MfSPKZuU3/gz+EcFea...Q47SWKsETB0qdkhkpviDOnCWT1bmwL9YWUCcTQfwsRumE4kA/ARV/9Np8L9U38w0Y/0xZh+V3/gLZnrCRLzI3pws1pRgvrlv6SCnkLtA42nDhg87ygsw8c'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE & 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key: Nonce must be between 8 and 128 bytes



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.33s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE & 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C735740CB0>

encrypted_payload = 'CDGESol+5+Ax6UFCwjllSbePrRYm8fh+brmwBaBQOUpjpu/T8Iy50iDtOUpU8pOP8Pdz5iNJH0WNXFeSP45AzaxiTmHR5wYgWEMYaBvx+jOUIAmewpO/v...oV9Fd/msu2Kw5dXrjPIhhubXfHRGoj2ITbDFEbZUZj3CxpGKq/CxJtCgUy5EzdxApWZPu4boA6DRcvg3bp0PQjr/cGFcSyXrb1UmEIkj+Gb9HUco8j41gv'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE & 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C737B5B6E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C735740CB0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2284/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C735740CB0>

encrypted_payload = 'CDGESol+5+Ax6UFCwjllSbePrRYm8fh+brmwBaBQOUpjpu/T8Iy50iDtOUpU8pOP8Pdz5iNJH0WNXFeSP45AzaxiTmHR5wYgWEMYaBvx+jOUIAmewpO/v...oV9Fd/msu2Kw5dXrjPIhhubXfHRGoj2ITbDFEbZUZj3CxpGKq/CxJtCgUy5EzdxApWZPu4boA6DRcvg3bp0PQjr/cGFcSyXrb1UmEIkj+Gb9HUco8j41gv'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE & 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt ^ nonce + ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1862b7208e850882: unsupported operand type(s) for ^: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C7536D5940>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C75255F710>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C75255F710>

payload = {'id': 'cef3456c-bdfb-4362-93b4-65ba7ebf5867', 'salt': 'TbfuwoiD8JdzEem2f2mXpQ==', 'secret': 'unit-test-secret', 'timestamp': 1760722557, ...}

key = b'}\xf1mf\ty,:{(A*\xeaE\x0c\xc5\xae\x12\\\r\x1e\xea\x8a\xae\xf6\x05A{(\xfa\xd6\xe2'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt ^ nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C7536D7890>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C75255F710>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1311/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C75255F710>

payload = {'id': 'b20a9ce3-e540-4ec6-8933-f19f887bed05', 'salt': '4p16dzI3sQZJCBUqxK4L1Q==', 'secret': 'unit-test-secret', 'timestamp': 1760722557, ...}

key = b'xh\xbf\x08\xf4\xdf`\xe9\x87\x0c$T\xe6\x84\xeb&\x07\x1eMKsg\xc6p\xb31\xcd1P;\xf2\xe6'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt ^ nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001C7537016D0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp9c6fw623.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C75255F710>

payload = {'id': '3de34c77-1a0b-423b-aaa4-22dfef3973c8', 'salt': 'PgkXsQQ491Ln6D+Bk5YIDw==', 'secret': 'test-secret', 'timestamp': 1760722557, ...}

key = b'J\xe8\\.\x13u\x88\x06\xf9%\rjy\xb3\xbaK1\x18\x16\xaaS\xc5X\xba\xa6>\x99\xee\xcbOq\x91'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt ^ nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001C7537018B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpg903tnhl.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C75255F710>

payload = {'id': 'c7374443-5410-4c6d-95bb-7cd60b4a1da4', 'salt': 'oJgvcIGKHKDQ35YTq2sICw==', 'secret': 'test-secret', 'timestamp': 1760722558, ...}

key = b'\xac\xf9\xb6\xc2F3p\xcf\x99\x0b?\x0e\xf8\xf2\x0e\xf9i\xedw\xf6g\xb8\xf6A\x07\xe4\xect\xda\xde\x9f\xea'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt ^ nonce + ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -271,7 +271,7 @@
         salt = base64.b64decode(payload["salt"])
 
         # Combine salt, nonce, and ciphertext
-        encrypted = salt + nonce + ciphertext
+        encrypted = salt + nonce ^ ciphertext
         return base64.b64encode(encrypted).decode("ascii")
 
     def _decrypt_payload(self, key: bytes) -> dict[str, Any]:
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'bytes' and 'bytes'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ef0dd7d9c6ab34943: unsupported operand type(s) for ^: 'bytes' and 'bytes'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001FAF57396A0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FAF293F380>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FAF293F380>

payload = {'id': '53b345be-aec9-4c9d-903b-238803154b63', 'salt': 'BUuBN+wkPKfIPS5YphwwTA==', 'secret': 'unit-test-secret', 'timestamp': 1760712899, ...}

key = b't\x9cD\x8b\xa1\x199>(2\xb1\xbc\xb8\x8a@u&\xd0\xd6\x87\xe6\xca\xd8\x86\xfc\x8c\xa0z\xb7\xe2_\xc1'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce ^ ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001FAF573B8C0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FAF293F380>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-876/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FAF293F380>

payload = {'id': 'e3bfff27-eecd-403a-b410-47fa979af6b7', 'salt': '8C+8sz2R/vn+0rrRAbckVg==', 'secret': 'unit-test-secret', 'timestamp': 1760712900, ...}

key = b'Oq\xe7GM,8\x82\x17\xde\xb6\xb1\xffs\xf4\x92xk\xa1\xc6]b\x17\x9aml\x7f\x8a\x99\x1a\xd8#'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce ^ ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001FAF5761730>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmphvqzx5vs.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FAF293F380>

payload = {'id': '279f6257-d2df-4c6a-ae0f-a309174133a9', 'salt': 'PCKV1gfENNT1h8HGC4mLdg==', 'secret': 'test-secret', 'timestamp': 1760712900, ...}

key = b'\xa8f\x9e\xc0\xd5i\xbc)\x06\xd5\xcch/L\xdf8Q\xc8\xb0\xe2\xb8B\x86\xb2\x0b\x91g\xd9i\xeb\xbe\xef'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce ^ ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001FAF5761910>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpgd2rf3ws.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001FAF293F380>

payload = {'id': '9ecce6a9-24b2-4183-9aae-f8bd3ef944da', 'salt': 'lKweMva6UexD72hQSHfyXg==', 'secret': 'test-secret', 'timestamp': 1760712900, ...}

key = b'\xc7F\xbc\x83t\xb3\xd9n\x03\x1f\xaeAL\x85\xd9\t\\\xdf\x95m\xe6\x90\xba\xb2\xaf\xf6+V\xea&\x85\xba'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

        aesgcm = AESGCM(key)

        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM

    

        payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")

        ciphertext = aesgcm.encrypt(nonce, payload_json, None)

    

        # Include salt from payload in the encrypted data for easier extraction

        salt = base64.b64decode(payload["salt"])

    

        # Combine salt, nonce, and ciphertext

>       encrypted = salt + nonce ^ ciphertext

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'bytes' and 'bytes'



robust_xmp_watermark.py:274: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.69s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT ^ 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.50s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -327,7 +327,7 @@
 
         for i in range(self._FRAGMENT_COUNT):
             start = i * fragment_size
-            end = min(start + fragment_size, len(payload_bytes))
+            end = min(start ^ fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE ^ 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.34s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE ^ 12]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE ^ 12 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Mul_Add, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i + fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.32s

operator: core/ReplaceBinaryOperator_Mul_Sub, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i - fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Mul_Div, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i / fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
.............FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eaf8d1741b07e32b1: slice indices must be integers or None or have an __index__ method

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001870BF658E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018708216150>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018708216150>

doc = Document('None', <memory, doc# 11>)

encrypted_payload = '04XJirV1RF2CLfeP9Ohqy17UnwX7P5AL802VYkyqZw9j1k+N7xgD4/sa90mXFvh6WUASszf4KCo2ICfYysQTwSOcbrSrfK/i9nPxoiDy9PqLrjfAbs8St...apB998K2ETJpcEDOfxuobpRTQXPtsiyWSLOHDZy4him9Omic6uTj+vULxbA65E1fhtvMUbMFREyyiEj9A6GMkQ724ENhJcRsKnR0gg4PJyjhwbMIIQscg7'

watermark_id = '24b60359-f06f-4138-8717-ed3cdeb4eb84'

key = b'{\xf7U\xee\x8a\xb4\xe0\x1b!\xc9\xfb\xe0\xcbu\xe75(\xd6\xefb\x1a\x9f\x8f\xb4Y\xec\x19\x0f\x03\x08\xec\xec'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i / fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001870BF67950>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018708216150>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1299/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018708216150>

doc = Document('None', <memory, doc# 17>)

encrypted_payload = 'a+ZhkpF4ND4YNB5AY2zbePVIKKKppOraInqbz3z1Unxj5QNuXNAGYnIAXWq2TsoTDsmaKwqKj1BItDrV7t8jpm7pgYCvtIOwcXcXsgtSWon8ved1IhKN/...Stp2EwzG/rNgqa48Pkp//csFmjvA70BPmeAcGPCzkcsZKWfLV3CDcV/WpjqZPBKgQSm/80v/CCe3PXQ6C4K/a/Nk2Tb/TR2f8tF6uhiSZgzKh5jf5uaGAs'

watermark_id = 'e21e6c84-2f51-4910-b374-4a352a38c88f'

key = b'\x01\x94\xcd\xa7I"y\xf0z\xc4\xbe\xc0l\x83R\x15\xff\xcc\xe6~Y\x08\r\x88\xf8\x13Y,\xfd\xc9[H'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i / fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001870BF8D760>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpbzahemq9.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018708216150>

doc = Document('None', <memory, doc# 26>)

encrypted_payload = 'GvgdxMPrSm4i7u0psrt7URPuvhtPMGNOA4Sae2z/N4zFEv6f2oCyZu8REFUcVZ4cS+MJ4Ozp62HcmGsmiOHgl3zvX6ObLN2a4n9Rw6goyZs1zJDnLgl8T...ljCxBoph8GeZ3h48HoopxLazQLPTORpAmFqEimppf95wlXqpOrCFrXb3VMYS9UrcRPwfety2XCX0k5h+G+PgSW7omGPATB3Udf4lHJypZBCAkgrSdgsw=='

watermark_id = '4f3666dc-dccf-4d83-9b47-6cb5ebe9dc61'

key = b'q\xef\xd9\x7ftp\xd6\x90\xf8\xbd\xd8Z\x80g\x95\xd7F\xa6\xcf\x84\x07\xfe\xa8\xa0\x01!P\x13v\x9d\xf2\xc6'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i / fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001870BF8D940>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpdk4qn1z3.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018708216150>

doc = Document('None', <memory, doc# 28>)

encrypted_payload = 'mpJCcaftpAA/zlxBoVm+ByH1N7z+Je/jzeGwM8mOhQwvyv3bkl1KR4IuYEf45r/QLH6/XFnYBb2YUcC3E3Y2qmHNAGPkrWpwlnY/xG0btGAJTAgu+uGMG...pLFEe7s3f2vaDmym5bwhqPhrmqOna3phEaMJeWhSmU2FXQicLE+sd7/ZX0QBK21mclLpVUxOyK5l5xrl/+2CSWQZPhfN8VE0qWuDWn++iyuqhU5LByiA=='

watermark_id = '95b224c6-84fe-484c-9de6-659dac900619'

key = b'\xef\xb5]7/\x88\x8b\x07\xa3t\xf5\xbb1B4\x84\xce\xe0\xd4&\x02}\x89m6-.g&\x92\xae\xe5'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i / fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

6 failed, 36 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Mul_FloorDiv, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i // fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Mul_Mod, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i % fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_Mul_Pow, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i ** fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Mul_RShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i >> fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.33s

operator: core/ReplaceBinaryOperator_Mul_LShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i << fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Mul_BitOr, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i | fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.45s

operator: core/ReplaceBinaryOperator_Mul_BitAnd, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i & fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Mul_BitXor, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -326,7 +326,7 @@
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
-            start = i * fragment_size
+            start = i ^ fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
             fragments.append(fragment)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_FloorDiv_Add, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) + self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_FloorDiv_Sub, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) - self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T110042647748Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T110043579404Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.55s

operator: core/ReplaceBinaryOperator_FloorDiv_Mul, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) * self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_FloorDiv_Div, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) / self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
.............FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614edd4118f3500ae7cf: slice indices must be integers or None or have an __index__ method

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001A0BB4B9430>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A0B837B260>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A0B837B260>

doc = Document('None', <memory, doc# 11>)

encrypted_payload = 'BA6FdRyLusvRHMeR5lmc7VzZpbPgiF7ldwyF7UFlaKdDC4n9acoSNCwh3oytGGjrVGbFlza7z8dFwcLgnnc/FX6mTxJ3xf3fZ2WLiN0QUJWY8KQQHfNKr...kVLvjr4+as8HZAY4ASMMYQac1iAV1HtU7XdWivKoALRN/zYSr4LKAjeG7BZ3iZMRn0WFkdAYDyso+B70rFhQUc5KNVA5RCi4JDHOBU2P5naGe2dEjinn6V'

watermark_id = 'e8fdfa9e-855b-4e99-bfb0-b12e5c622b3d'

key = b'\xd4\x8d\x97\xac"\xd1\x12D\x14f/\xb4.\xae\xb5\x9bfA\x1d\xc0s\xb7\x92\xf7B\x93\xecf\xf4\x07\xbb\x03'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) / self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001A0BB4BB650>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A0B837B260>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-993/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A0B837B260>

doc = Document('None', <memory, doc# 17>)

encrypted_payload = 'ZYNmf9IUBCbSvV8G9c6aC18LK409c3d+6gdBKuW5haQOYI7pydCWa8dA/CcFfMlreH3Sg6PFMqKcQ3V2YX/Cp6F0whnBijzujPgS5glBLOWF/9mMbQKzZ...aSiU4hs3/+I3AeiRD57fTxGQJFetSpDMJYXcS60C9H9z4EORTW6mlbUHNHPr6bjV8btlUzJhX1c3n7Qh22Gqefl89SJprQbUanP9HXQb78fkPYsahxrBvb'

watermark_id = '17530d89-8d7b-469d-9f3f-49e57dee950e'

key = b'\x95\x8c\xfd\x13n\xa5\x81\x90L\x80$@%\xe9\xd8\x89\xad\xec\xf4%\xf8n|`\xf3\xa2\x07[Z\x1fVC'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) / self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001A0BB4E14C0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp2jm2jlja.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A0B837B260>

doc = Document('None', <memory, doc# 26>)

encrypted_payload = 'J6E7Nxs4FKmdV2k67i37lKfV3X9kVBTJQmpwMGtfg4n5p9tC7Rvqi17odc0lfl2c8yIFD/KybW66oONoKwgvi38enYusgF9qeRYyeuVfkPerLsc2wrxJ1...4clTWTeahPwSs0fAH4ESAMqZmsQHRtQ0dyQ6HaPlVHbQ3Xus7AeI8oMBOA0aToZER4WBSmIOYOKe5LnkmscuQpevZPLLQ3I6NNOEswfqxItbfh5wjr0Q=='

watermark_id = 'd0d64ae8-f4e8-4a44-9754-ec3f78939f5e'

key = b'O\xb9Z\x93Y\x15(BS\xad\xf0\xb0\xc3\x98\xdbV\\rl\xbbLm\x0b<\xaf\x85\xdbO\x0fh\x95\xd5'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) / self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001A0BB4E16A0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpm6mklsvb.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:168: in add_watermark

    self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001A0B837B260>

doc = Document('None', <memory, doc# 28>)

encrypted_payload = '5+Zk48x1wE1VCofYjESyAZbe2ST0aasBUnRdCf6DApBCIAF0Lj3bPrPWpIeCqeyuVc52EV7bHu4elmbu9UDI8kcGVMcm7ajHoGt6CIrMa4bKQv6TLvoqp...ya+UGM5jKjcJD2Ev6gpVvZQIKo0hON+AZhNJ/rYcp4tG+dYiUZOsDmLO+dTGqplfx+w1aSFypVU4hIagfgTlf+NLBp1VkkTFwTmHUJatNJ5E8Epz0hkg=='

watermark_id = 'a53029fd-2193-4eb1-b105-b8130f36a86f'

key = b'\xce\x81\xa7\xb3\x1c\xd0\x10\x0c\xa0#s\xd3N3\xf2u\xadw\xa4ac\xca\x0b\x07\xb7y\xe5\x89\x1e\x00\x1c\xe0'



    def _embed_fragments(

        self,

        doc: fitz.Document,

        encrypted_payload: str,

        watermark_id: str,

        key: bytes,

    ) -> None:

        """Distribute watermark fragments across PDF objects."""

        # Split payload into fragments

        payload_bytes = encrypted_payload.encode("utf-8")

        fragment_size = len(payload_bytes) / self._FRAGMENT_COUNT + 1

        fragments = []

    

        for i in range(self._FRAGMENT_COUNT):

            start = i * fragment_size

            end = min(start + fragment_size, len(payload_bytes))

>           fragment = payload_bytes[start:end]

                       ^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: slice indices must be integers or None or have an __index__ method



robust_xmp_watermark.py:331: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

6 failed, 36 passed, 23 warnings in 21.13s

operator: core/ReplaceBinaryOperator_FloorDiv_Mod, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) % self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_FloorDiv_Pow, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) ** self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_FloorDiv_RShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) >> self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/ReplaceBinaryOperator_FloorDiv_LShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) << self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_FloorDiv_BitOr, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) | self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 23.35s

operator: core/ReplaceBinaryOperator_FloorDiv_BitAnd, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) & self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_FloorDiv_BitXor, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) ^ self._FRAGMENT_COUNT + 1
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str + None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str + None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T202109150463Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T202110006113Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.46s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str + None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T182158988621Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T182159844319Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.58s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str - None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.64s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str - None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str - None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str * None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str * None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str * None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T004107605569Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T004108457986Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.19s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str / None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str / None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str / None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.66s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str // None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102549844999Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102550736796Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str // None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str // None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.23s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str % None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str % None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str % None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str ** None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str ** None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str ** None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T132946637469Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T132947535219Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.52s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str >> None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str >> None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str >> None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.69s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str << None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str << None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.56s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str << None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T141234076293Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T141234980637Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.63s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str & None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str & None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str & None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -97,7 +97,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -98,7 +98,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         """Add a robust watermark to the PDF.
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -191,7 +191,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -347,7 +347,7 @@
                 # If we can't add annotations, skip fragments
                 continue
 
-    def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
+    def _extract_from_xmp(self, doc: fitz.Document) -> str ^ None:
         """Extract watermark from XMP metadata (document info implementation)."""
         try:
             metadata = doc.metadata
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -372,7 +372,7 @@
             pass
         return None
 
-    def _extract_from_document_info(self, doc: fitz.Document) -> str | None:
+    def _extract_from_document_info(self, doc: fitz.Document) -> str ^ None:
         """Extract watermark from document info dictionary."""
         try:
             metadata = doc.metadata
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144433198143Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144434093415Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.59s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -387,7 +387,7 @@
             pass
         return None
 
-    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str | None:
+    def _reconstruct_from_fragments(self, doc: fitz.Document) -> str ^ None:
         """Reconstruct watermark from distributed fragments."""
         try:
             fragments = {}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count != 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") != self._VERSION
                 ):
                     return payload["secret"]
 
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C5061EB830>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C5035E18B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1186/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001C5035E18B0>

encrypted_payload = '81V7hZGyB07L3Zv9U/r082fHgqorBWHHoVv7raUJD00GU+9fnw+A5vfz0GRQrzS0A3G0+Go+1r4bfYa10hHWQHUNIaNdGZl3dAcs8r5e0jWFp6uIEySDC...2KYle6Vs6mKYAjSjAEibSMhG/lHOWfDjpxZojO+DB7heVOOkuIaP+N4APV2CunYX6GZWDK0Nw3gAFAD4wikObBXGbM4FmpXeCQiVLgeYWOBClXBTu6XFOt'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") != self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.06s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count < 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") < self._VERSION
                 ):
                     return payload["secret"]
 
.FFF.F.F.FFF.........F....................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T224321999540Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T224322824895Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000166EC3479B0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000166EB1D9550>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2151/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000166EB1D9550>

encrypted_payload = 'ZEEV7gs+B6t69HhKb6jnhF2TsXtQ/e2uvgyWs8DYKpMmpyrxXs4l84aWNSmzjm2AQ+NjAhpMkuGHGNwGSDsYSnXIjawCe9pxruNRKTO0iXQB3JHRySfHB...1ChHEMQO+8HYcA+6Lr+aY4wgoxkycpdW7Cg4788sgPEBaVqrqfnvIQ8sAdVCuHJiMvYjKOkl7g85DmRXndJMufySPS7V2YI0a6G2LlwAq0UAFu7rrtRSA6'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") < self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

9 failed, 33 passed, 23 warnings in 20.44s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count <= 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.57s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") <= self._VERSION
                 ):
                     return payload["secret"]
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count > 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") > self._VERSION
                 ):
                     return payload["secret"]
 
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000018BF6D479E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018BF41959A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-940/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018BF41959A0>

encrypted_payload = 'wH0CnDFZbA4bacHY9tWZqMVnJoq9tQta+flNpHEbw0OVmDvUNYgwSRCvmE6LZ2UqszuawG35ktpfbH9dLyH9KlvUG3KjRl9AclJv2SUp1wu/28DVCblf8...KYWOaJ+SXLcEpIibNzSRiNpDP9Mg8Np+0282H8nOxj0Zlu9HvZEHS8HQC4dH+Xb6q/ktdkhcKr83S7Vr2GqW3RiBYx5kP9Ay/f1jUKmmwP2zzR/aXhcQ7Q'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") > self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 23.59s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count >= 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") >= self._VERSION
                 ):
                     return payload["secret"]
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") is self._VERSION
                 ):
                     return payload["secret"]
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    and payload.get("version") is not self._VERSION
                 ):
                     return payload["secret"]
 
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B124A9F230>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B1226B8F80>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-481/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B1226B8F80>

encrypted_payload = 'u+PJEy8WQjJue1MzKhgvIwtCWM1wRNqfcsyajNIjZZn+c1aawYFEtkwAxY70redznFwBipbqaoyVG3osoeaa0Nh6BgbiQfOjmZVOP0BJ0eZskj+8Hu9S5...Zb/0ZaMDbl1Lk3S6NTS5AiV5OR8c24U09/Y6GUR1uOwqHUWu7W14A0eOASTI57i213rsHlT7NqsQvxSarFpOfgFoUP36kjYUAR6iBS1xD8gWtqo7QVhYnd'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") is not self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.15s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position == "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position < "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
.............FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6ca6ee0d67d48aa4: '<' not supported between instances of 'NoneType' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000029A98269610>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000029A9571E390>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000029A9571E390>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position < "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '<' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000029A9826B620>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000029A9571E390>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-800/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000029A9571E390>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position < "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '<' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000029A98291400>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpa8n8pl1o.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000029A9571E390>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpa8n8pl1o.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position < "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '<' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000029A982915E0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpj5awe_ex.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000029A9571E390>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpj5awe_ex.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position < "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '<' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

6 failed, 36 passed, 23 warnings in 21.28s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position <= "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
.............FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e4f48e44c5937e503: '<=' not supported between instances of 'NoneType' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000018AD90D58B0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018AD6F7FEF0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018AD6F7FEF0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position <= "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '<=' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000018AD90D7980>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018AD6F7FEF0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2266/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018AD6F7FEF0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position <= "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '<=' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000018AD90FD7C0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp366365r7.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018AD6F7FEF0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp366365r7.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position <= "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '<=' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000018AD90FD9A0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpwere2g3t.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000018AD6F7FEF0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpwere2g3t.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position <= "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '<=' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

6 failed, 36 passed, 23 warnings in 21.05s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position > "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
.............FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1299dcea7bb925f2: '>' not supported between instances of 'NoneType' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F6B17C5820>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F6B06B2000>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F6B06B2000>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position > "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '>' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F6B17C7B00>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F6B06B2000>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1527/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F6B06B2000>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position > "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '>' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F6B17E9940>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpj2kofxj1.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F6B06B2000>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpj2kofxj1.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position > "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '>' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001F6B17E9B20>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpcps36ohn.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001F6B06B2000>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpcps36ohn.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position > "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '>' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

6 failed, 36 passed, 23 warnings in 22.02s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position >= "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
.............FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ee843967d74cc81e2: '>=' not supported between instances of 'NoneType' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B76DDB54F0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B76CCD95B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B76CCD95B0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position >= "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '>=' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B76DDB7920>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B76CCD95B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-57/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B76CCD95B0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position >= "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '>=' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001B76DDE1790>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp4ube6abh.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B76CCD95B0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp4ube6abh.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position >= "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '>=' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001B76DDE1970>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp5lxy00ub.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B76CCD95B0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp5lxy00ub.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        # Generate watermark components

        salt = secrets.token_bytes(self._SALT_SIZE)

        timestamp = int(time.time())

        watermark_id = str(uuid.uuid4())

    

        # Derive encryption key

        derived_key = self._derive_key(key, salt)

    

        # Create watermark payload

        payload = {

            "version": self._VERSION,

            "id": watermark_id,

            "timestamp": timestamp,

            "secret": secret,

            "salt": base64.b64encode(salt).decode("ascii"),

        }

    

        # Encrypt the payload

        encrypted_payload = self._encrypt_payload(payload, derived_key)

    

        # Open PDF with PyMuPDF

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Ensure the PDF has at least one page for fragment embedding

            if doc.page_count == 0:

                try:

                    # Try to add a blank page if PDF structure allows it

                    doc.new_page()

                except RuntimeError:

                    # PDF structure is too minimal, use metadata-only approach

                    position = "metadata-only"

    

        except Exception:

            # If there are any issues, fall back to metadata-only

            position = "metadata-only"

    

        # Add watermark to XMP metadata

        self._embed_in_xmp(doc, encrypted_payload, watermark_id)

    

        # Add backup to document info

        self._embed_in_document_info(doc, encrypted_payload, watermark_id)

    

        # Add distributed fragments (unless disabled or not possible)

>       if position >= "metadata-only":

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: '>=' not supported between instances of 'NoneType' and 'str'



robust_xmp_watermark.py:167: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

6 failed, 36 passed, 23 warnings in 21.59s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position is "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



robust_xmp_watermark.py:167

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\robust_xmp_watermark.py:167: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if position is "metadata-only":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 20.87s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if position is not "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



robust_xmp_watermark.py:167

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\robust_xmp_watermark.py:167: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    if position is not "metadata-only":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 20.94s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count == 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.48s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count != 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count < 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count <= 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count >= 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) == 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.25s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) == 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.29s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) == self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) == self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022784A6B800>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022781F54950>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-388/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022781F54950>

encrypted_payload = 'Czrqh8rNqshGb2RaE1Lvf6pB4mYhmgqEVueibl0XwFB01HMElZ5JiK2VLOlH+Z3yrL5dqmXkpRWEtaaWJikeaEdH3EitRycEDRcddW8Yi5XIR1B/bORXh...b4Lc1CMDRCHEdur4f3Ody0umOC+M9dJddyTggGEM8OdQX/jgMcoa5//7ZEIYesRZTVC3bqxkYCqZnJwUhGCXYQGsTG4RueNVCYCsPD0z/kPgbKEoY2KcDo'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) == self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.05s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) != 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) != 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) != self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215636709197Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215637617550Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.63s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) != self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.67s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) < 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) < 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) < self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) < self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BA90AF77A0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001BA8F97E210>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1239/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001BA8F97E210>

encrypted_payload = 'PmslrGLFzJKgeGgXi9tEBR+XLDrJj4uYWsI4om7fUpePa7XBNfa1VTWhvPU3cWttkPXCaHKomMtIw5vYHS1aPn/6e2DaQ7WWsHdNmBFuHl/mEDoLY4IJ6...mhxY0/eRByE5cIjLsZunFuq0/rW/2JW+6iUStdTraL3DuDs0Xh82s1e24XATh9+Vv5VTnwcniQEMupstsjQ3tykhXDAauXbzQJF7lBn+lHweJLITkh7jE6'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) < self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.10s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) <= 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) <= 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) <= self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) <= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000016E1AA179B0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000016E188BCDD0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2437/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000016E188BCDD0>

encrypted_payload = 'kKBPb/RCWUWjARWkbWnKYyHfajWf+Kq4fgIgg2rDW2bqWBfdDdqm+9acDnTTKpOZtEW1GlyeoJFqqXvj5AtRUxlW9tXcjSgosf0U04SmW7aKSnPDhMEtW...kTC9iQpvjGHzXHOgKUD3mgAB0ObeYFTzIAnRAcqFswFiYpudulEP39DauptKdz/IHzhFX+J0bxf2Qc+N24UQNkczIyrVMP+LGg72YO1r38rOpOapztj698'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) <= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.84s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) > 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) > 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) > self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) > self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceComparisonOperator_GtE_Is, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) is self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T153501429730Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T153502283256Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.64s

operator: core/ReplaceComparisonOperator_GtE_Is, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) is self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000168B639B560>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000168B522BC50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1163/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000168B522BC50>

encrypted_payload = 'CJqubKxYoNaPz01yMeXVihXUSoqTDQ1i8Y3NSXjXSVJqUWvarAUzOevaVGaRCkS8aABOOQXWpRIsuV/2T69t1dhK1IPaHaKB8suaw+pA91ZLoLdKtLdTf...N+6frrKXDvoamdzLmS25arBIlDJRcB9JGL0O2LSIXat3ZJwCBRitevFxW+r1rCYEp654sZ/RdnfYZMaAmc8UVl/r94qWJO72PgWdjd7IKZiGKhZFR5TtxD'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) is self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.20s

operator: core/ReplaceComparisonOperator_GtE_IsNot, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if len(fragments) is not self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceComparisonOperator_GtE_IsNot, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) is not self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -111,7 +111,7 @@
         Returns:
             Watermarked PDF as bytes
         """
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: PyMuPDF is required for robust XMP watermarking

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614eed17f81c671c75c7: PyMuPDF is required for robust XMP watermarking

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000230993E9490>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000230968056D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000230968056D0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if  HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:115: WatermarkingError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000230993EB800>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000230968056D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1796/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000230968056D0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if  HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:115: WatermarkingError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000230994115E0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpq9kgwrmm.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000230968056D0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpq9kgwrmm.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if  HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:115: WatermarkingError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000230994117C0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpjnurnkyg.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000230968056D0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpjnurnkyg.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if  HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:115: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.55s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -115,7 +115,7 @@
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
-        if not secret.strip():
+        if  secret.strip():
             raise ValueError("Secret must be a non-empty string")
         if not key.strip():
             raise ValueError("Key must be a non-empty string")
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Secret must be a non-empty string

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ec9d364d7a1a0a601: Secret must be a non-empty string

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000029431F85760>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002942FE34F50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002942FE34F50>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if  secret.strip():

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



robust_xmp_watermark.py:119: ValueError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000029431F87920>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002942FE34F50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-786/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002942FE34F50>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if  secret.strip():

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



robust_xmp_watermark.py:119: ValueError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000029431FB1790>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp55occxij.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002942FE34F50>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp55occxij.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if  secret.strip():

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



robust_xmp_watermark.py:119: ValueError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000029431FB1970>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpn16l2o37.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002942FE34F50>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpn16l2o37.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if  secret.strip():

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



robust_xmp_watermark.py:119: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.69s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -117,7 +117,7 @@
         data = load_pdf_bytes(pdf)
         if not secret.strip():
             raise ValueError("Secret must be a non-empty string")
-        if not key.strip():
+        if  key.strip():
             raise ValueError("Key must be a non-empty string")
 
         # Generate watermark components
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Key must be a non-empty string

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6c42001ce69a7ffa: Key must be a non-empty string

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000132B5315700>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000132B4187710>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000132B4187710>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if  key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:121: ValueError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000132B53178C0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000132B4187710>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-233/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000132B4187710>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if  key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:121: ValueError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000132B5341700>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp0f926hq9.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000132B4187710>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp0f926hq9.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if  key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:121: ValueError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000132B53418E0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp5ir65wc5.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000132B4187710>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp5ir65wc5.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if  key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:121: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.68s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -194,7 +194,7 @@
         position: str | None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             return False
 
         try:
.........F...FFs..s..s....................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 36 passed, 3 skipped, 23 warnings in 20.48s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -219,7 +219,7 @@
             SecretNotFoundError: If no watermark is found
             InvalidKeyError: If key is incorrect
         """
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000218A7A279E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000218A5641940>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-591/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000218A5641940>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-591/test_read_secret_roundtrip_rob0/robust-xmp_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        """Extract and decrypt the watermark secret.

    

        Args:

            pdf: Watermarked PDF

            key: Decryption key

    

        Returns:

            Extracted secret

    

        Raises:

            SecretNotFoundError: If no watermark is found

            InvalidKeyError: If key is incorrect

        """

        if  HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:223: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 20.86s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -223,7 +223,7 @@
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
-        if not key.strip():
+        if  key.strip():
             raise ValueError("Key must be a non-empty string")
 
         doc = fitz.open(stream=data, filetype="pdf")
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000021D01C3B800>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021D7F0BB590>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1446/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000021D7F0BB590>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1446/test_read_secret_roundtrip_rob0/robust-xmp_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        """Extract and decrypt the watermark secret.

    

        Args:

            pdf: Watermarked PDF

            key: Decryption key

    

        Returns:

            Extracted secret

    

        Raises:

            SecretNotFoundError: If no watermark is found

            InvalidKeyError: If key is incorrect

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if  key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:227: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.14s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -232,7 +232,7 @@
             # Try to read from document info first (more reliable for full payload)
             encrypted_payload = self._extract_from_document_info(doc)
 
-            if not encrypted_payload:
+            if  encrypted_payload:
                 # Fallback to XMP metadata
                 encrypted_payload = self._extract_from_xmp(doc)
 
.FFF.F.F.FFF.........F....................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T212213757935Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T212214574643Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000028158C45CD0>

encrypted_payload = 'GNUDLCm1FBVhB+6z0aETsAiJII4zKzj0k+YwR3OWmbOqT0f5vVTnkXrmckC3G7FTDQuzmhly9x0ZJD9lUzeJQajsm6FXA4URpwsy'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002815B837A10>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000028158C45CD0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1930/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000028158C45CD0>

encrypted_payload = 'GNUDLCm1FBVhB+6z0aETsAiJII4zKzj0k+YwR3OWmbOqT0f5vVTnkXrmckC3G7FTDQuzmhly9x0ZJD9lUzeJQajsm6FXA4URpwsy'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

9 failed, 33 passed, 23 warnings in 20.53s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 7
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -236,7 +236,7 @@
                 # Fallback to XMP metadata
                 encrypted_payload = self._extract_from_xmp(doc)
 
-            if not encrypted_payload:
+            if  encrypted_payload:
                 # Last resort: try to reconstruct from fragments
                 encrypted_payload = self._reconstruct_from_fragments(doc)
 
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019E845AB950>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019E818DB080>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1419/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019E818DB080>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1419/test_read_secret_roundtrip_rob0/robust-xmp_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        """Extract and decrypt the watermark secret.

    

        Args:

            pdf: Watermarked PDF

            key: Decryption key

    

        Returns:

            Extracted secret

    

        Raises:

            SecretNotFoundError: If no watermark is found

            InvalidKeyError: If key is incorrect

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Try to read from document info first (more reliable for full payload)

            encrypted_payload = self._extract_from_document_info(doc)

    

            if not encrypted_payload:

                # Fallback to XMP metadata

                encrypted_payload = self._extract_from_xmp(doc)

    

            if  encrypted_payload:

                # Last resort: try to reconstruct from fragments

                encrypted_payload = self._reconstruct_from_fragments(doc)

    

            if not encrypted_payload:

>               raise SecretNotFoundError("No robust XMP watermark found in PDF")

E               watermarking_method.SecretNotFoundError: No robust XMP watermark found in PDF



robust_xmp_watermark.py:244: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.20s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 8
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -240,7 +240,7 @@
                 # Last resort: try to reconstruct from fragments
                 encrypted_payload = self._reconstruct_from_fragments(doc)
 
-            if not encrypted_payload:
+            if  encrypted_payload:
                 raise SecretNotFoundError("No robust XMP watermark found in PDF")
 
             # Decrypt and extract secret
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000012690A8B7A0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001268DEF2840>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2082/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001268DEF2840>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2082/test_read_secret_roundtrip_rob0/robust-xmp_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        """Extract and decrypt the watermark secret.

    

        Args:

            pdf: Watermarked PDF

            key: Decryption key

    

        Returns:

            Extracted secret

    

        Raises:

            SecretNotFoundError: If no watermark is found

            InvalidKeyError: If key is incorrect

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Try to read from document info first (more reliable for full payload)

            encrypted_payload = self._extract_from_document_info(doc)

    

            if not encrypted_payload:

                # Fallback to XMP metadata

                encrypted_payload = self._extract_from_xmp(doc)

    

            if not encrypted_payload:

                # Last resort: try to reconstruct from fragments

                encrypted_payload = self._reconstruct_from_fragments(doc)

    

            if  encrypted_payload:

>               raise SecretNotFoundError("No robust XMP watermark found in PDF")

E               watermarking_method.SecretNotFoundError: No robust XMP watermark found in PDF



robust_xmp_watermark.py:244: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.08s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -111,7 +111,7 @@
         Returns:
             Watermarked PDF as bytes
         """
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: PyMuPDF is required for robust XMP watermarking

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ebb9e363c12b9865e: PyMuPDF is required for robust XMP watermarking

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B340335640>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B33F15E090>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B33F15E090>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not not HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:115: WatermarkingError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B340337A40>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B33F15E090>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-778/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B33F15E090>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not not HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:115: WatermarkingError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001B34035D8B0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpxb_grz3b.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B33F15E090>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpxb_grz3b.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not not HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:115: WatermarkingError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001B34035DA90>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpkb0rmq_a.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001B33F15E090>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpkb0rmq_a.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not not HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:115: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.86s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -115,7 +115,7 @@
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
-        if not secret.strip():
+        if not not secret.strip():
             raise ValueError("Secret must be a non-empty string")
         if not key.strip():
             raise ValueError("Key must be a non-empty string")
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Secret must be a non-empty string

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614ed41c1ee8943c29a7: Secret must be a non-empty string

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001EF217A5610>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EF1EF1EC60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EF1EF1EC60>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not not secret.strip():

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



robust_xmp_watermark.py:119: ValueError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001EF217A7A10>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EF1EF1EC60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2184/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EF1EF1EC60>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not not secret.strip():

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



robust_xmp_watermark.py:119: ValueError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001EF217CD820>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpuz5igr6n.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EF1EF1EC60>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpuz5igr6n.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not not secret.strip():

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



robust_xmp_watermark.py:119: ValueError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001EF217CDA00>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpqeyqph2m.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EF1EF1EC60>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpqeyqph2m.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not not secret.strip():

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



robust_xmp_watermark.py:119: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.50s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -117,7 +117,7 @@
         data = load_pdf_bytes(pdf)
         if not secret.strip():
             raise ValueError("Secret must be a non-empty string")
-        if not key.strip():
+        if not not key.strip():
             raise ValueError("Key must be a non-empty string")
 
         # Generate watermark components
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: Key must be a non-empty string

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e6d17777eb36a20a4: Key must be a non-empty string

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000285DDA09940>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000285DB5C2990>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000285DB5C2990>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not not key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:121: ValueError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000285DDA0B920>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000285DB5C2990>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1529/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000285DB5C2990>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not not key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:121: ValueError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000285DDA31760>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmplqg233k5.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000285DB5C2990>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmplqg233k5.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not not key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:121: ValueError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000285DDA31940>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp9lo2ort9.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000285DB5C2990>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp9lo2ort9.pdf')

secret = 'test-secret', key = 'test-key', intended_for = None, position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        """Add a robust watermark to the PDF.

    

        Args:

            pdf: Source PDF to watermark

            secret: Secret to embed

            key: Password for encryption

            position: Optional position hint ('metadata-only' for simpler embedding)

    

        Returns:

            Watermarked PDF as bytes

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not secret.strip():

            raise ValueError("Secret must be a non-empty string")

        if not not key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:121: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 20.66s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if not doc.page_count == 0:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -164,7 +164,7 @@
         self._embed_in_document_info(doc, encrypted_payload, watermark_id)
 
         # Add distributed fragments (unless disabled or not possible)
-        if position != "metadata-only":
+        if not position != "metadata-only":
             self._embed_fragments(doc, encrypted_payload, watermark_id, derived_key)
 
         # Return the watermarked PDF
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -171,7 +171,7 @@
         try:
             result = doc.write()
         except ValueError as e:
-            if "cannot save with zero pages" in str(e):
+            if not "cannot save with zero pages" in str(e):
                 # Create a new document with proper structure
                 new_doc = fitz.open()
                 new_doc.new_page()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.38s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -194,7 +194,7 @@
         position: str | None = None,
     ) -> bool:
         """Check if watermarking is applicable."""
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             return False
 
         try:
.........F...FFs..s..s....................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 36 passed, 3 skipped, 23 warnings in 20.46s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -219,7 +219,7 @@
             SecretNotFoundError: If no watermark is found
             InvalidKeyError: If key is incorrect
         """
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000268B68479E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000268B66B21B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2243/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000268B66B21B0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2243/test_read_secret_roundtrip_rob0/robust-xmp_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        """Extract and decrypt the watermark secret.

    

        Args:

            pdf: Watermarked PDF

            key: Decryption key

    

        Returns:

            Extracted secret

    

        Raises:

            SecretNotFoundError: If no watermark is found

            InvalidKeyError: If key is incorrect

        """

        if not not HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

E           watermarking_method.WatermarkingError: PyMuPDF is required for robust XMP watermarking



robust_xmp_watermark.py:223: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 20.94s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -223,7 +223,7 @@
             raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")
 
         data = load_pdf_bytes(pdf)
-        if not key.strip():
+        if not not key.strip():
             raise ValueError("Key must be a non-empty string")
 
         doc = fitz.open(stream=data, filetype="pdf")
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019788ABB650>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019784D26150>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1036/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000019784D26150>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1036/test_read_secret_roundtrip_rob0/robust-xmp_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        """Extract and decrypt the watermark secret.

    

        Args:

            pdf: Watermarked PDF

            key: Decryption key

    

        Returns:

            Extracted secret

    

        Raises:

            SecretNotFoundError: If no watermark is found

            InvalidKeyError: If key is incorrect

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not not key.strip():

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



robust_xmp_watermark.py:227: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.14s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -232,7 +232,7 @@
             # Try to read from document info first (more reliable for full payload)
             encrypted_payload = self._extract_from_document_info(doc)
 
-            if not encrypted_payload:
+            if not not encrypted_payload:
                 # Fallback to XMP metadata
                 encrypted_payload = self._extract_from_xmp(doc)
 
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000027E3CE3F650>

encrypted_payload = 'yqScdxuizk3xUxuu6b4Qmo09diPoKNOGgE+Ls56OcRSG+XLclAeNocVgMqiCVuNXG44FRgTRfdorvwKJOJwHbocbeq5jAp0NDSWu'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000027E3FC07800>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000027E3CE3F650>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2465/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000027E3CE3F650>

encrypted_payload = 'yqScdxuizk3xUxuu6b4Qmo09diPoKNOGgE+Ls56OcRSG+XLclAeNocVgMqiCVuNXG44FRgTRfdorvwKJOJwHbocbeq5jAp0NDSWu'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 20.89s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -236,7 +236,7 @@
                 # Fallback to XMP metadata
                 encrypted_payload = self._extract_from_xmp(doc)
 
-            if not encrypted_payload:
+            if not not encrypted_payload:
                 # Last resort: try to reconstruct from fragments
                 encrypted_payload = self._reconstruct_from_fragments(doc)
 
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001760BA6B800>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017608FC11F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1658/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000017608FC11F0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1658/test_read_secret_roundtrip_rob0/robust-xmp_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        """Extract and decrypt the watermark secret.

    

        Args:

            pdf: Watermarked PDF

            key: Decryption key

    

        Returns:

            Extracted secret

    

        Raises:

            SecretNotFoundError: If no watermark is found

            InvalidKeyError: If key is incorrect

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Try to read from document info first (more reliable for full payload)

            encrypted_payload = self._extract_from_document_info(doc)

    

            if not encrypted_payload:

                # Fallback to XMP metadata

                encrypted_payload = self._extract_from_xmp(doc)

    

            if not not encrypted_payload:

                # Last resort: try to reconstruct from fragments

                encrypted_payload = self._reconstruct_from_fragments(doc)

    

            if not encrypted_payload:

>               raise SecretNotFoundError("No robust XMP watermark found in PDF")

E               watermarking_method.SecretNotFoundError: No robust XMP watermark found in PDF



robust_xmp_watermark.py:244: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.15s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -240,7 +240,7 @@
                 # Last resort: try to reconstruct from fragments
                 encrypted_payload = self._reconstruct_from_fragments(doc)
 
-            if not encrypted_payload:
+            if not not encrypted_payload:
                 raise SecretNotFoundError("No robust XMP watermark found in PDF")
 
             # Decrypt and extract secret
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001913B0DB740>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001913AF421B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2176/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001913AF421B0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2176/test_read_secret_roundtrip_rob0/robust-xmp_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        """Extract and decrypt the watermark secret.

    

        Args:

            pdf: Watermarked PDF

            key: Decryption key

    

        Returns:

            Extracted secret

    

        Raises:

            SecretNotFoundError: If no watermark is found

            InvalidKeyError: If key is incorrect

        """

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for robust XMP watermarking")

    

        data = load_pdf_bytes(pdf)

        if not key.strip():

            raise ValueError("Key must be a non-empty string")

    

        doc = fitz.open(stream=data, filetype="pdf")

    

        try:

            # Try to read from document info first (more reliable for full payload)

            encrypted_payload = self._extract_from_document_info(doc)

    

            if not encrypted_payload:

                # Fallback to XMP metadata

                encrypted_payload = self._extract_from_xmp(doc)

    

            if not encrypted_payload:

                # Last resort: try to reconstruct from fragments

                encrypted_payload = self._reconstruct_from_fragments(doc)

    

            if not not encrypted_payload:

>               raise SecretNotFoundError("No robust XMP watermark found in PDF")

E               watermarking_method.SecretNotFoundError: No robust XMP watermark found in PDF



robust_xmp_watermark.py:244: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.13s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if not doc.page_count > 0:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.34s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -358,7 +358,7 @@
             producer = metadata.get("producer", "")
 
             # Check if this looks like our watermark format
-            if "watermark" in keywords and "Tatou Security" in producer:
+            if not "watermark" in keywords and "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T234251245236Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T234252122210Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.39s

operator: core/AddNot, occurrence: 14
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -360,7 +360,7 @@
             # Check if this looks like our watermark format
             if "watermark" in keywords and "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
-                if "tw-" in subject:
+                if not "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
                     if len(parts) >= 3:
                         return parts[2]  # The encrypted payload part
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.33s

operator: core/AddNot, occurrence: 15
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if not len(parts) >= 3:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/AddNot, occurrence: 16
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -366,7 +366,7 @@
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
-                if title:
+                if not title:
                     return title
         except Exception:  # nosec B110  # noqa: S110
             pass
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.21s

operator: core/AddNot, occurrence: 17
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -380,7 +380,7 @@
             title = metadata.get("title", "")
 
             # Check if this looks like our watermark format
-            if creator.startswith("Tatou-") and title:
+            if not creator.startswith("Tatou-") and title:
                 # The full payload is stored in title
                 return title
         except Exception:  # nosec B110  # noqa: S110
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000016670ED21B0>

encrypted_payload = 'bEaBgaVYcVmjRjDhzxpHLWlveSGd6ULFHabTSy+qge8qMjDp1xtVOXU74j/1VwzZPHUL+vBOyuH1WMZfOpD0tAvY6P9m1AX+Q0WY'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000016671067A70>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000016670ED21B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1532/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000016670ED21B0>

encrypted_payload = 'bEaBgaVYcVmjRjDhzxpHLWlveSGd6ULFHabTSy+qge8qMjDp1xtVOXU74j/1VwzZPHUL+vBOyuH1WMZfOpD0tAvY6P9m1AX+Q0WY'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.09s

operator: core/AddNot, occurrence: 18
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -402,7 +402,7 @@
                         content = annot.info.get("content", "")
                         author = annot.info.get("title", "")  # Sometimes title is used
 
-                        if author.startswith("tw-") and content:
+                        if not author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
                             if len(parts) >= 2:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/AddNot, occurrence: 19
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if not len(parts) >= 2:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/AddNot, occurrence: 20
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -415,7 +415,7 @@
                         continue
 
             # Reconstruct payload from fragments
-            if len(fragments) >= self._MIN_FRAGMENTS:
+            if not len(fragments) >= self._MIN_FRAGMENTS:
                 reconstructed = b""
                 for i in sorted(fragments.keys()):
                     reconstructed += fragments[i]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/AddNot, occurrence: 21
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if not len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022BBCF67830>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022BBAD8E150>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-945/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022BBAD8E150>

encrypted_payload = 'F68/g85OM3yygs8aAN8LFg9D/7iuCTGnmqC+d5ryj1wIdFo07RbaE207GI3Q9gvuP2oZdIwW/aoq5c3dqSX81DWpqvg6PNs9jpYCVmXzw6gkcL11fl8zc...1jiO6DzStPsI8EsuIglpcKSD4pCWXhXM2FT8DwVofC5h8AnuRYCvXPGW/sFRdGswqhU1XWmZ8U6C2jXxHm8dlOnEkDeAfJ4Lgv1iEIHaUK1GtOq7Oc5w5k'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if not len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.54s

operator: core/AddNot, occurrence: 22
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -446,7 +446,7 @@
                 payload = json.loads(payload_json.decode("utf-8"))
 
                 # Validate payload structure
-                if (
+                if not (
                     isinstance(payload, dict)
                     and payload.get("version") == self._VERSION
                 ):
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BCE2A67950>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001BCDFAEB080>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-866/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001BCDFAEB080>

encrypted_payload = '6hPfNENf00Sz7WRJpuXDCBwf2IA7Wtns/crpPdHdib9ZWqExE1c53jMz3WdpCxc8sHuvr0/M5TQ6X+RclFtuNfNdZLuxaBB2FyzQoEzxdXx1DMbr2TSXT...WsjhFcI4OhY+/Rb/PVeqnx6x/S0FhLU23p50hC7El/E4SyoNAX4zvx0EOkH4JPaa+DxLe455Waq+ZPn+Vtctwa5nBumjIGb/0E8uOjdpxx3A0FZ0IC7fTO'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if not (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

>           raise SecretNotFoundError("Invalid watermark format or corrupted data")

E           watermarking_method.SecretNotFoundError: Invalid watermark format or corrupted data



robust_xmp_watermark.py:456: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.20s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -50,7 +50,7 @@
 try:
     import fitz  # PyMuPDF
 
-    HAS_PYMUPDF = True
+    HAS_PYMUPDF = False
 except ImportError:
     HAS_PYMUPDF = False
 
.........F...FFs..s..s....................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 36 passed, 3 skipped, 23 warnings in 20.43s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -201,7 +201,7 @@
             data = load_pdf_bytes(pdf)
             doc = fitz.open(stream=data, filetype="pdf")
             doc.close()
-            return True
+            return False
         except Exception:
             return False
 
.........F...FFs..s..s....................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 36 passed, 3 skipped, 23 warnings in 20.61s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -52,7 +52,7 @@
 
     HAS_PYMUPDF = True
 except ImportError:
-    HAS_PYMUPDF = False
+    HAS_PYMUPDF = True
 
 
 class RobustXmpWatermark(WatermarkingMethod):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -195,7 +195,7 @@
     ) -> bool:
         """Check if watermarking is applicable."""
         if not HAS_PYMUPDF:
-            return False
+            return True
 
         try:
             data = load_pdf_bytes(pdf)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/ReplaceFalseWithTrue, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -203,7 +203,7 @@
             doc.close()
             return True
         except Exception:
-            return False
+            return True
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         """Extract and decrypt the watermark secret.
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 23.31s

operator: core/ReplaceAndWithOr, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -358,7 +358,7 @@
             producer = metadata.get("producer", "")
 
             # Check if this looks like our watermark format
-            if "watermark" in keywords and "Tatou Security" in producer:
+            if "watermark" in keywords or "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceAndWithOr, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -380,7 +380,7 @@
             title = metadata.get("title", "")
 
             # Check if this looks like our watermark format
-            if creator.startswith("Tatou-") and title:
+            if creator.startswith("Tatou-") or title:
                 # The full payload is stored in title
                 return title
         except Exception:  # nosec B110  # noqa: S110
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceAndWithOr, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -402,7 +402,7 @@
                         content = annot.info.get("content", "")
                         author = annot.info.get("title", "")  # Sometimes title is used
 
-                        if author.startswith("tw-") and content:
+                        if author.startswith("tw-") or content:
                             # Extract fragment index
                             parts = author.split("-")
                             if len(parts) >= 2:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceAndWithOr, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -448,7 +448,7 @@
                 # Validate payload structure
                 if (
                     isinstance(payload, dict)
-                    and payload.get("version") == self._VERSION
+                    or payload.get("version") == self._VERSION
                 ):
                     return payload["secret"]
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceContinueWithBreak, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -345,7 +345,7 @@
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
-                continue
+                break
 
     def _extract_from_xmp(self, doc: fitz.Document) -> str | None:
         """Extract watermark from XMP metadata (document info implementation)."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/ReplaceContinueWithBreak, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -410,7 +410,7 @@
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
                                 except (ValueError, TypeError):
-                                    continue
+                                    break
                     except Exception:  # nosec B112  # noqa: S112
                         continue
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.58s

operator: core/ReplaceContinueWithBreak, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -412,7 +412,7 @@
                                 except (ValueError, TypeError):
                                     continue
                     except Exception:  # nosec B112  # noqa: S112
-                        continue
+                        break
 
             # Reconstruct payload from fragments
             if len(fragments) >= self._MIN_FRAGMENTS:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -51,7 +51,7 @@
     import fitz  # PyMuPDF
 
     HAS_PYMUPDF = True
-except ImportError:
+except CosmicRayTestingException:
     HAS_PYMUPDF = False
 
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -149,7 +149,7 @@
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
-                except RuntimeError:
+                except CosmicRayTestingException:
                     # PDF structure is too minimal, use metadata-only approach
                     position = "metadata-only"
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -153,7 +153,7 @@
                     # PDF structure is too minimal, use metadata-only approach
                     position = "metadata-only"
 
-        except Exception:
+        except CosmicRayTestingException:
             # If there are any issues, fall back to metadata-only
             position = "metadata-only"
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -170,7 +170,7 @@
         # Return the watermarked PDF
         try:
             result = doc.write()
-        except ValueError as e:
+        except CosmicRayTestingException as e:
             if "cannot save with zero pages" in str(e):
                 # Create a new document with proper structure
                 new_doc = fitz.open()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -202,7 +202,7 @@
             doc = fitz.open(stream=data, filetype="pdf")
             doc.close()
             return True
-        except Exception:
+        except CosmicRayTestingException:
             return False
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.82s

operator: core/ExceptionReplacer, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -343,7 +343,7 @@
                     # Add as form field or annotation
                     page.add_text_annot([0, 0], fragment_b64)
 
-            except Exception:  # nosec B112  # noqa: S112
+            except CosmicRayTestingException:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
                 continue
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ExceptionReplacer, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -368,7 +368,7 @@
                 # Fallback to title (full payload)
                 if title:
                     return title
-        except Exception:  # nosec B110  # noqa: S110
+        except CosmicRayTestingException:  # nosec B110  # noqa: S110
             pass
         return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ExceptionReplacer, occurrence: 7
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -383,7 +383,7 @@
             if creator.startswith("Tatou-") and title:
                 # The full payload is stored in title
                 return title
-        except Exception:  # nosec B110  # noqa: S110
+        except CosmicRayTestingException:  # nosec B110  # noqa: S110
             pass
         return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/ExceptionReplacer, occurrence: 8
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -409,7 +409,7 @@
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
-                                except (ValueError, TypeError):
+                                except (CosmicRayTestingException, TypeError):
                                     continue
                     except Exception:  # nosec B112  # noqa: S112
                         continue
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ExceptionReplacer, occurrence: 9
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -409,7 +409,7 @@
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
-                                except (ValueError, TypeError):
+                                except (ValueError, CosmicRayTestingException):
                                     continue
                     except Exception:  # nosec B112  # noqa: S112
                         continue
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ExceptionReplacer, occurrence: 10
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -411,7 +411,7 @@
                                     fragments[fragment_idx] = base64.b64decode(content)
                                 except (ValueError, TypeError):
                                     continue
-                    except Exception:  # nosec B112  # noqa: S112
+                    except CosmicRayTestingException:  # nosec B112  # noqa: S112
                         continue
 
             # Reconstruct payload from fragments
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ExceptionReplacer, occurrence: 11
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -421,7 +421,7 @@
                     reconstructed += fragments[i]
                 return reconstructed.decode("utf-8")
 
-        except Exception:  # nosec B110  # noqa: S110
+        except CosmicRayTestingException:  # nosec B110  # noqa: S110
             pass
         return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ExceptionReplacer, occurrence: 12
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -455,7 +455,7 @@
             # If the above doesn't work, raise an error
             raise SecretNotFoundError("Invalid watermark format or corrupted data")
 
-        except InvalidKeyError:
+        except CosmicRayTestingException:
             raise
         except SecretNotFoundError:
             raise
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.57s

operator: core/ExceptionReplacer, occurrence: 13
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -457,7 +457,7 @@
 
         except InvalidKeyError:
             raise
-        except SecretNotFoundError:
+        except CosmicRayTestingException:
             raise
         except Exception as e:
             msg = f"Failed to decrypt watermark with provided key: {e}"
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T131225020521Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T131225905342Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.63s

operator: core/ExceptionReplacer, occurrence: 14
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -459,7 +459,7 @@
             raise
         except SecretNotFoundError:
             raise
-        except Exception as e:
+        except CosmicRayTestingException as e:
             msg = f"Failed to decrypt watermark with provided key: {e}"
             raise InvalidKeyError(msg) from e
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -77,7 +77,7 @@
     # Constants for the watermarking scheme
     _XMP_NAMESPACE: Final[str] = "http://tatou.security/watermark/"
     _XMP_PREFIX: Final[str] = "tw"
-    _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
+    _FRAGMENT_COUNT: Final[int] = 4  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -77,7 +77,7 @@
     # Constants for the watermarking scheme
     _XMP_NAMESPACE: Final[str] = "http://tatou.security/watermark/"
     _XMP_PREFIX: Final[str] = "tw"
-    _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
+    _FRAGMENT_COUNT: Final[int] = 2  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T180255520738Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T180256529211Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.61s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -78,7 +78,7 @@
     _XMP_NAMESPACE: Final[str] = "http://tatou.security/watermark/"
     _XMP_PREFIX: Final[str] = "tw"
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
-    _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
+    _MIN_FRAGMENTS: Final[int] = 3  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -78,7 +78,7 @@
     _XMP_NAMESPACE: Final[str] = "http://tatou.security/watermark/"
     _XMP_PREFIX: Final[str] = "tw"
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
-    _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
+    _MIN_FRAGMENTS: Final[int] = 1  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -79,7 +79,7 @@
     _XMP_PREFIX: Final[str] = "tw"
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
-    _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
+    _SALT_SIZE: Final[int] = 17  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -79,7 +79,7 @@
     _XMP_PREFIX: Final[str] = "tw"
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
-    _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
+    _SALT_SIZE: Final[int] = 15  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -80,7 +80,7 @@
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
-    _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
+    _KEY_ITERATIONS: Final[int] = 100001  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
 
     @staticmethod
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.56s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -80,7 +80,7 @@
     _FRAGMENT_COUNT: Final[int] = 3  # Number of fragments to distribute
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
-    _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
+    _KEY_ITERATIONS: Final[int] = 99999  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
 
     @staticmethod
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -81,7 +81,7 @@
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
-    _VERSION: Final[int] = 1  # Watermark format version
+    _VERSION: Final[int] = 2  # Watermark format version
 
     @staticmethod
     def get_usage() -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -81,7 +81,7 @@
     _MIN_FRAGMENTS: Final[int] = 2  # Minimum fragments needed for reconstruction
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
-    _VERSION: Final[int] = 1  # Watermark format version
+    _VERSION: Final[int] = 0  # Watermark format version
 
     @staticmethod
     def get_usage() -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count == 1:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.31s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -145,7 +145,7 @@
 
         try:
             # Ensure the PDF has at least one page for fragment embedding
-            if doc.page_count == 0:
+            if doc.page_count == -1:
                 try:
                     # Try to add a blank page if PDF structure allows it
                     doc.new_page()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -253,7 +253,7 @@
         """Derive encryption key from password and salt."""
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,  # 256-bit key
+            length= 33,  # 256-bit key
             salt=salt,
             iterations=self._KEY_ITERATIONS,
         )
.........F...FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: AESGCM key must be 128, 192, or 256 bits.

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e2ef881b54a38486a: AESGCM key must be 128, 192, or 256 bits.

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026DA9E15670>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026DA8DFAEA0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026DA8DFAEA0>

payload = {'id': '447c8b2b-7c1d-485b-a4df-aafc12b37b8d', 'salt': 'cqZUhI5nuIMSkPLSo9cbDQ==', 'secret': 'unit-test-secret', 'timestamp': 1760733339, ...}

key = b'_\xdd\x945hx{T\x1fS\\\x9d\n\x8cJ\x80*\xd7!\xcc\xb7S\xc8\x04\xf0\xeaV\xde\x1f\xd0\x01\xae\x1c'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

>       aesgcm = AESGCM(key)

                 ^^^^^^^^^^^

E       ValueError: AESGCM key must be 128, 192, or 256 bits.



robust_xmp_watermark.py:264: ValueError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026DA9E17AA0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026DA8DFAEA0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1800/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026DA8DFAEA0>

payload = {'id': 'd1ec3705-156a-47fe-8997-83f97127d87c', 'salt': 'lclemiE0B9MZ3+c8ojA/4Q==', 'secret': 'unit-test-secret', 'timestamp': 1760733339, ...}

key = b'\x98y\xbd\x00g\xdc\xf4\xbd\xdc\xaa\x97}\xec\x8a\xbd\xb2\xe9\xf3\x078\x9a\xe0\x1d\xbc\x01\x07\x10\xbf\x02\x95f\xcd&'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

>       aesgcm = AESGCM(key)

                 ^^^^^^^^^^^

E       ValueError: AESGCM key must be 128, 192, or 256 bits.



robust_xmp_watermark.py:264: ValueError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000026DA9E3D880>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpmznv8uxd.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026DA8DFAEA0>

payload = {'id': 'e7826db9-78c0-4619-85a6-d3335d525584', 'salt': 'uagcGl2GkS7g6kH1iLVbVw==', 'secret': 'test-secret', 'timestamp': 1760733340, ...}

key = b'\x1e\xdb\x13\x0e\xbf{\x99*G\xe2\x9c\xfeKX8)\xe0\xb6\xea\x94\xae#\x9c\x88\xa0\xf0\na\x92\xaf\x04t\x7f'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

>       aesgcm = AESGCM(key)

                 ^^^^^^^^^^^

E       ValueError: AESGCM key must be 128, 192, or 256 bits.



robust_xmp_watermark.py:264: ValueError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000026DA9E3DA60>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpklluwwrn.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000026DA8DFAEA0>

payload = {'id': '034663f2-bb20-4bda-9106-b8949bbd773f', 'salt': 'm6oE3+XJBGTvsFpdbF3deQ==', 'secret': 'test-secret', 'timestamp': 1760733340, ...}

key = b'V\x94@Ae\xab\xc8-\x18Zu\xa9\x8ee\xe6\x8c\xc6\x05\xbb\xe9Hk\x0b\xa5\x80o\xcc\x88m\xab\xb6~\x1c'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

>       aesgcm = AESGCM(key)

                 ^^^^^^^^^^^

E       ValueError: AESGCM key must be 128, 192, or 256 bits.



robust_xmp_watermark.py:264: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

7 failed, 35 passed, 23 warnings in 21.18s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -253,7 +253,7 @@
         """Derive encryption key from password and salt."""
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,  # 256-bit key
+            length= 31,  # 256-bit key
             salt=salt,
             iterations=self._KEY_ITERATIONS,
         )
.FFF.F.F.FFF.FF...F..F.........FF.........                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T152158731729Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T152159593804Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e010fbcfa488f8e5d: AESGCM key must be 128, 192, or 256 bits.

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

_____ TestAllWatermarkingMethods.test_add_watermark_and_shape[robust-xmp] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022D02F458E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022D00E0E120>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022D00E0E120>

payload = {'id': 'b54e7d9e-a1fe-446c-b67a-97079c98a851', 'salt': 'ufEmlPUHuqSyaxYdMWmRjw==', 'secret': 'unit-test-secret', 'timestamp': 1760714524, ...}

key = b'\xb9]\x11\x1f\x19\x1b$\xc4`\xd8\x147m5\x10T6\x998\xf3T\x04s&6\xa5\x81\x88(\xa8~'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

>       aesgcm = AESGCM(key)

                 ^^^^^^^^^^^

E       ValueError: AESGCM key must be 128, 192, or 256 bits.



robust_xmp_watermark.py:264: ValueError

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022D02F478C0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022D00E0E120>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-952/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022D00E0E120>

payload = {'id': '3b7fe459-dc95-4de9-82d4-26409d959685', 'salt': 'rS7khllJSUD4AZXpk7Ut2A==', 'secret': 'unit-test-secret', 'timestamp': 1760714524, ...}

key = b'\xe1\xbb\xb1\xe7n\xfd\xf1\xe5p!C|U\xd0nI.3\x1a\xeeQOI\xe5\xfb4\xfa\n\xfe@\xef'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

>       aesgcm = AESGCM(key)

                 ^^^^^^^^^^^

E       ValueError: AESGCM key must be 128, 192, or 256 bits.



robust_xmp_watermark.py:264: ValueError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000022D02F71700>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp5y_ck5x3.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method_name,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",

            )



..\test\test_watermarking_utilities.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022D00E0E120>

payload = {'id': '4e598caf-21b0-4c68-aa3f-abfedf8df2dc', 'salt': 'ZDfpr9Rl5vrNRdlziojYwA==', 'secret': 'test-secret', 'timestamp': 1760714525, ...}

key = b"\xcc[\x80t\xd1\xdd'#:\x93\xd0\xe22\xda\x8f\x03\x1a\xf9\x9f\xaa\xb9U\xbb\x9a\xee\x91\xd5\xb5s\xbf?"



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

>       aesgcm = AESGCM(key)

                 ^^^^^^^^^^^

E       ValueError: AESGCM key must be 128, 192, or 256 bits.



robust_xmp_watermark.py:264: ValueError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000022D02F718E0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp433v2nrb.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

        if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

>           result = WMUtils.apply_watermark(

                method=method,

                pdf=sample_pdf_path,

                secret="test-secret",  # pragma: allowlist secret

                key="test-key",  # pragma: allowlist secret

            )



..\test\test_watermarking_utilities.py:140: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:101: in apply_watermark

    return m.add_watermark(

robust_xmp_watermark.py:141: in add_watermark

    encrypted_payload = self._encrypt_payload(payload, derived_key)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022D00E0E120>

payload = {'id': '71858795-87f8-4403-9798-9323aee11055', 'salt': 'VJsfk3fNZgq6A/KF5QalLw==', 'secret': 'test-secret', 'timestamp': 1760714525, ...}

key = b'\x83\xb6\xf1\xde,\xad\x16)K\xe3\x0e\xe3Y%\x82\x98p\x10x\x08e\xf8\x91\xd8\x04\xfa\xdd9|\xfa\xfb'



    def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:

        """Encrypt payload using AES-GCM and include salt."""

>       aesgcm = AESGCM(key)

                 ^^^^^^^^^^^

E       ValueError: AESGCM key must be 128, 192, or 256 bits.



robust_xmp_watermark.py:264: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[robust-xmp]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

14 failed, 28 passed, 23 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -262,7 +262,7 @@
     def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:
         """Encrypt payload using AES-GCM and include salt."""
         aesgcm = AESGCM(key)
-        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM
+        nonce = secrets.token_bytes( 13)  # 96-bit nonce for GCM
 
         payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")
         ciphertext = aesgcm.encrypt(nonce, payload_json, None)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022BF41D6990>

encrypted_payload = 'h+G5tkYvlGZmoAPI4ALtXT3DEmLnbNEhV63YAvHrHRVT1MDpvHGARJQO9i3jT6DvafyTTJ7uE3QFrUsfn0WsweF4VDX1J7Cialuf8dJSGucMIX/ZRdgaw...eXzU1Hw26bdixYi3PnENrY+rCBFkfdD5hr8Rf5eJWHwGsV9OAiUxCv07MDdwHmVR2ZZNKfP25wuyG8FSKcr9vT3RmX5Gnuca1Ryi0mffhh/Y5/KWqK+g=='

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022BF6D2F320>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022BF41D6990>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-961/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x0000022BF41D6990>

encrypted_payload = 'h+G5tkYvlGZmoAPI4ALtXT3DEmLnbNEhV63YAvHrHRVT1MDpvHGARJQO9i3jT6DvafyTTJ7uE3QFrUsfn0WsweF4VDX1J7Cialuf8dJSGucMIX/ZRdgaw...eXzU1Hw26bdixYi3PnENrY+rCBFkfdD5hr8Rf5eJWHwGsV9OAiUxCv07MDdwHmVR2ZZNKfP25wuyG8FSKcr9vT3RmX5Gnuca1Ryi0mffhh/Y5/KWqK+g=='

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.29s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -262,7 +262,7 @@
     def _encrypt_payload(self, payload: dict[str, Any], key: bytes) -> str:
         """Encrypt payload using AES-GCM and include salt."""
         aesgcm = AESGCM(key)
-        nonce = secrets.token_bytes(12)  # 96-bit nonce for GCM
+        nonce = secrets.token_bytes( 11)  # 96-bit nonce for GCM
 
         payload_json = json.dumps(payload, separators=(",", ":")).encode("utf-8")
         ciphertext = aesgcm.encrypt(nonce, payload_json, None)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001AE03BB2840>

encrypted_payload = 'atW7wh0842uuAC6LgCShp+2Fe8du+jD+sBBYEDeSl88dN9eYbE7SalNLYDhWU9AOF4R/d5UMcIcCOzJHs7OsaVxBoF+p3f6P+DsV+FFZjJy8saMmaVLDW...//yhr/+bHBTrmInEvhVi7RsZ3J+5m1B8ICvThTeMT6NKjNvgpg6JZeW9OII8Ldi4EupiMPmbMGr3k4/yiAp1fW8VB2zLcf7CVQayj6yANlZ4bcIzMkj6Q='

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001AE066CB6E0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001AE03BB2840>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2199/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001AE03BB2840>

encrypted_payload = 'atW7wh0842uuAC6LgCShp+2Fe8du+jD+sBBYEDeSl88dN9eYbE7SalNLYDhWU9AOF4R/d5UMcIcCOzJHs7OsaVxBoF+p3f6P+DsV+FFZjJy8saMmaVLDW...//yhr/+bHBTrmInEvhVi7RsZ3J+5m1B8ICvThTeMT6NKjNvgpg6JZeW9OII8Ldi4EupiMPmbMGr3k4/yiAp1fW8VB2zLcf7CVQayj6yANlZ4bcIzMkj6Q='

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.15s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -291,7 +291,7 @@
         # Use a combination of standard and custom fields
         metadata.update(
             {
-                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[:100]}",
+                "subject": f"tw-{watermark_id[: 9]}-{encrypted_payload[:100]}",
                 "keywords": f"watermark,{watermark_id}",
                 "producer": f"Tatou Security Watermarker v{self._VERSION}",
             }
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -291,7 +291,7 @@
         # Use a combination of standard and custom fields
         metadata.update(
             {
-                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[:100]}",
+                "subject": f"tw-{watermark_id[: 7]}-{encrypted_payload[:100]}",
                 "keywords": f"watermark,{watermark_id}",
                 "producer": f"Tatou Security Watermarker v{self._VERSION}",
             }
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -291,7 +291,7 @@
         # Use a combination of standard and custom fields
         metadata.update(
             {
-                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[:100]}",
+                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[: 101]}",
                 "keywords": f"watermark,{watermark_id}",
                 "producer": f"Tatou Security Watermarker v{self._VERSION}",
             }
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -291,7 +291,7 @@
         # Use a combination of standard and custom fields
         metadata.update(
             {
-                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[:100]}",
+                "subject": f"tw-{watermark_id[:8]}-{encrypted_payload[: 99]}",
                 "keywords": f"watermark,{watermark_id}",
                 "producer": f"Tatou Security Watermarker v{self._VERSION}",
             }
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -306,7 +306,7 @@
         metadata = doc.metadata
         metadata.update(
             {
-                "creator": f"Tatou-{watermark_id[:8]}",  # Partial ID in creator
+                "creator": f"Tatou-{watermark_id[: 9]}",  # Partial ID in creator
                 "title": encrypted_payload,  # Full payload in title (main storage)
             }
         )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -306,7 +306,7 @@
         metadata = doc.metadata
         metadata.update(
             {
-                "creator": f"Tatou-{watermark_id[:8]}",  # Partial ID in creator
+                "creator": f"Tatou-{watermark_id[: 7]}",  # Partial ID in creator
                 "title": encrypted_payload,  # Full payload in title (main storage)
             }
         )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 2
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -322,7 +322,7 @@
         """Distribute watermark fragments across PDF objects."""
         # Split payload into fragments
         payload_bytes = encrypted_payload.encode("utf-8")
-        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
+        fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 0
         fragments = []
 
         for i in range(self._FRAGMENT_COUNT):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count > 1:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -334,7 +334,7 @@
         # Add fragments to PDF as annotations or form fields
         for _i, fragment in enumerate(fragments):
             try:
-                if doc.page_count > 0:
+                if doc.page_count > -1:
                     page = doc.load_page(0)  # Use first page
 
                     # Create invisible annotation with fragment data
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -335,7 +335,7 @@
         for _i, fragment in enumerate(fragments):
             try:
                 if doc.page_count > 0:
-                    page = doc.load_page(0)  # Use first page
+                    page = doc.load_page( 1)  # Use first page
 
                     # Create invisible annotation with fragment data
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -335,7 +335,7 @@
         for _i, fragment in enumerate(fragments):
             try:
                 if doc.page_count > 0:
-                    page = doc.load_page(0)  # Use first page
+                    page = doc.load_page( -1)  # Use first page
 
                     # Create invisible annotation with fragment data
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -341,7 +341,7 @@
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
 
                     # Add as form field or annotation
-                    page.add_text_annot([0, 0], fragment_b64)
+                    page.add_text_annot([ 1, 0], fragment_b64)
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -341,7 +341,7 @@
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
 
                     # Add as form field or annotation
-                    page.add_text_annot([0, 0], fragment_b64)
+                    page.add_text_annot([ -1, 0], fragment_b64)
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -341,7 +341,7 @@
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
 
                     # Add as form field or annotation
-                    page.add_text_annot([0, 0], fragment_b64)
+                    page.add_text_annot([0, 1], fragment_b64)
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -341,7 +341,7 @@
                     fragment_b64 = base64.b64encode(fragment).decode("ascii")
 
                     # Add as form field or annotation
-                    page.add_text_annot([0, 0], fragment_b64)
+                    page.add_text_annot([0, -1], fragment_b64)
 
             except Exception:  # nosec B112  # noqa: S112
                 # If we can't add annotations, skip fragments
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -361,7 +361,7 @@
             if "watermark" in keywords and "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
-                    parts = subject.split("-", 2)  # tw-<id>-<payload>
+                    parts = subject.split("-", 3)  # tw-<id>-<payload>
                     if len(parts) >= 3:
                         return parts[2]  # The encrypted payload part
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.18s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -361,7 +361,7 @@
             if "watermark" in keywords and "Tatou Security" in producer:
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
-                    parts = subject.split("-", 2)  # tw-<id>-<payload>
+                    parts = subject.split("-", 1)  # tw-<id>-<payload>
                     if len(parts) >= 3:
                         return parts[2]  # The encrypted payload part
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) >= 4:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -362,7 +362,7 @@
                 # Try subject first (partial payload with watermark ID)
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
-                    if len(parts) >= 3:
+                    if len(parts) >= 2:
                         return parts[2]  # The encrypted payload part
 
                 # Fallback to title (full payload)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/NumberReplacer, occurrence: 36
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -363,7 +363,7 @@
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
                     if len(parts) >= 3:
-                        return parts[2]  # The encrypted payload part
+                        return parts[ 3]  # The encrypted payload part
 
                 # Fallback to title (full payload)
                 if title:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 37
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -363,7 +363,7 @@
                 if "tw-" in subject:
                     parts = subject.split("-", 2)  # tw-<id>-<payload>
                     if len(parts) >= 3:
-                        return parts[2]  # The encrypted payload part
+                        return parts[ 1]  # The encrypted payload part
 
                 # Fallback to title (full payload)
                 if title:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 38
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -393,7 +393,7 @@
             fragments = {}
 
             # Look for annotations with our fragment pattern
-            for page_num in range(min(doc.page_count, 5)):  # Check first few pages only
+            for page_num in range(min(doc.page_count, 6)):  # Check first few pages only
                 page = doc.load_page(page_num)
                 annots = page.annots()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 39
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -393,7 +393,7 @@
             fragments = {}
 
             # Look for annotations with our fragment pattern
-            for page_num in range(min(doc.page_count, 5)):  # Check first few pages only
+            for page_num in range(min(doc.page_count, 4)):  # Check first few pages only
                 page = doc.load_page(page_num)
                 annots = page.annots()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 40
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) >= 3:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 41
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -405,7 +405,7 @@
                         if author.startswith("tw-") and content:
                             # Extract fragment index
                             parts = author.split("-")
-                            if len(parts) >= 2:
+                            if len(parts) >= 1:
                                 try:
                                     fragment_idx = int(parts[1])
                                     fragments[fragment_idx] = base64.b64decode(content)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/NumberReplacer, occurrence: 42
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -407,7 +407,7 @@
                             parts = author.split("-")
                             if len(parts) >= 2:
                                 try:
-                                    fragment_idx = int(parts[1])
+                                    fragment_idx = int(parts[ 2])
                                     fragments[fragment_idx] = base64.b64decode(content)
                                 except (ValueError, TypeError):
                                     continue
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 43
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -407,7 +407,7 @@
                             parts = author.split("-")
                             if len(parts) >= 2:
                                 try:
-                                    fragment_idx = int(parts[1])
+                                    fragment_idx = int(parts[ 0])
                                     fragments[fragment_idx] = base64.b64decode(content)
                                 except (ValueError, TypeError):
                                     continue
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.49s

operator: core/NumberReplacer, occurrence: 44
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE + 13:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 45
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -431,7 +431,7 @@
             # Try to extract salt from the encrypted payload
             encrypted_data = base64.b64decode(encrypted_payload)
 
-            if len(encrypted_data) >= self._SALT_SIZE + 12:
+            if len(encrypted_data) >= self._SALT_SIZE + 11:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T154740291330Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T154741143012Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.46s

operator: core/NumberReplacer, occurrence: 46
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 13]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000251B623A630>

encrypted_payload = 'twlliFyWiOxUPJv/NyI79Rk1XZduy3ag0gDHTsVyEBCz+yK1q3wklsERvI0weP6AlaN+7ML5EgnksmcUDxBbjEyZGfRr3EkOzsgYVZRCjiVHtfMr+1D/o...bND9L0f+TLmiPg+27i9A/87D9vgsDRfF/57DqS7CnAQAPblj/kfLCKm4sxAs3K9C57QSwnPUKY23UZtAeQxKAt+WUrHUb0T18t7TeJN/kYJ64oDrqS3S+/'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 13]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000251B8D1B7D0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000251B623A630>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2318/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x00000251B623A630>

encrypted_payload = 'twlliFyWiOxUPJv/NyI79Rk1XZduy3ag0gDHTsVyEBCz+yK1q3wklsERvI0weP6AlaN+7ML5EgnksmcUDxBbjEyZGfRr3EkOzsgYVZRCjiVHtfMr+1D/o...bND9L0f+TLmiPg+27i9A/87D9vgsDRfF/57DqS7CnAQAPblj/kfLCKm4sxAs3K9C57QSwnPUKY23UZtAeQxKAt+WUrHUb0T18t7TeJN/kYJ64oDrqS3S+/'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 13]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.36s

operator: core/NumberReplacer, occurrence: 47
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -434,7 +434,7 @@
             if len(encrypted_data) >= self._SALT_SIZE + 12:
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
-                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
+                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 11]
                 ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
 
                 # Derive key using extracted salt
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002BC829212B0>

encrypted_payload = 'KgMycHj2a9zaxXMsDpKqCm/gMTcW8mvegjf1szcCzlwbIt7pvyqSsAIXkJmrcE3VKN5gtHxJUUnPHtvBNG2BuyPvLHOOaE/tl8DZtvFjkyF3qHiEuWz1T...66I+dDLe8inkl1LgdUNc3jB/VQlDcufBtFmxbpubxLvo96HxiFN7rgzXFcI7AEv8Yu5DKNUpbx8umOi2I3mXeUg3ct25U6ChSdogbB95vRU3mTAYeRsmz8'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 11]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002BC8542B560>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002BC829212B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1411/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000002BC829212B0>

encrypted_payload = 'KgMycHj2a9zaxXMsDpKqCm/gMTcW8mvegjf1szcCzlwbIt7pvyqSsAIXkJmrcE3VKN5gtHxJUUnPHtvBNG2BuyPvLHOOaE/tl8DZtvFjkyF3qHiEuWz1T...66I+dDLe8inkl1LgdUNc3jB/VQlDcufBtFmxbpubxLvo96HxiFN7rgzXFcI7AEv8Yu5DKNUpbx8umOi2I3mXeUg3ct25U6ChSdogbB95vRU3mTAYeRsmz8'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 11]

                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 48
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE + 13 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EB0D7058E0>

encrypted_payload = 'rWKYqPhtcZy7pdgNPK0SYyAM/ZRzZpvd/vj+lHoweBRL3ncbDVst1awfUFqUl/p1GkL1Rtj2YXBUCQ7XUt3+RW7CBCEj0eaYw8ykNQIv63QhCnkSueHvE...k3zW/wp/zF/2iY8zu7JIT40HHgULN+eUesheEqrqVvD9coFSJxn/dHVo0J/zE1PrHlJriW4rI8mPXqG/bQ1w8j008JzkYMhSZ6UubhbfeAW1AZdmDhtKKN'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 13 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001EB1024B7D0>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EB0D7058E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1934/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EB0D7058E0>

encrypted_payload = 'rWKYqPhtcZy7pdgNPK0SYyAM/ZRzZpvd/vj+lHoweBRL3ncbDVst1awfUFqUl/p1GkL1Rtj2YXBUCQ7XUt3+RW7CBCEj0eaYw8ykNQIv63QhCnkSueHvE...k3zW/wp/zF/2iY8zu7JIT40HHgULN+eUesheEqrqVvD9coFSJxn/dHVo0J/zE1PrHlJriW4rI8mPXqG/bQ1w8j008JzkYMhSZ6UubhbfeAW1AZdmDhtKKN'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 13 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.19s

operator: core/NumberReplacer, occurrence: 49
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -435,7 +435,7 @@
                 # Extract salt from beginning of encrypted data
                 salt = encrypted_data[: self._SALT_SIZE]
                 nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]
-                ciphertext = encrypted_data[self._SALT_SIZE + 12 :]
+                ciphertext = encrypted_data[self._SALT_SIZE + 11 :]
 
                 # Derive key using extracted salt
                 derived_key = self._derive_key(key, salt)
.....................F....................                               [100%]

================================== FAILURES ===================================

______ TestAllWatermarkingMethods.test_read_secret_roundtrip[robust-xmp] ______



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E6C83CDE50>

encrypted_payload = 'hW6xf4pffoePxfzcjO5mTGm01r+Qr+HtwIBmOu6Em5JAWLmaGtoXEsFzZYjU1T0hULzLiRfs3Tr44UnPaFAa9L8S/l0DrGat2EYu9pve9Eaz/HyxRwEgq...xcH9bEq7M3qTov+/g991F6OEz1lGG3iGts35wvFRrXq1pyhUsj5ZijQzCwNyPk53cZ1qWb5r0IoCn33tx5tTJ8u5h243vG1Etn2hQcyIKwGhCv+/3Q0rhq'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 11 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

>               payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E               cryptography.exceptions.InvalidTag



robust_xmp_watermark.py:445: InvalidTag



The above exception was the direct cause of the following exception:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E6C952B890>

method_name = 'robust-xmp'

impl = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E6C83CDE50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-75/test_read_secret_roundtrip_rob0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

robust_xmp_watermark.py:247: in read_secret

    return self._decrypt_and_extract_secret(encrypted_payload, key)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001E6C83CDE50>

encrypted_payload = 'hW6xf4pffoePxfzcjO5mTGm01r+Qr+HtwIBmOu6Em5JAWLmaGtoXEsFzZYjU1T0hULzLiRfs3Tr44UnPaFAa9L8S/l0DrGat2EYu9pve9Eaz/HyxRwEgq...xcH9bEq7M3qTov+/g991F6OEz1lGG3iGts35wvFRrXq1pyhUsj5ZijQzCwNyPk53cZ1qWb5r0IoCn33tx5tTJ8u5h243vG1Etn2hQcyIKwGhCv+/3Q0rhq'

key = 'unit-test-key'



    def _decrypt_and_extract_secret(self, encrypted_payload: str, key: str) -> str:

        """Decrypt payload and extract secret."""

        try:

            # Try to extract salt from the encrypted payload

            encrypted_data = base64.b64decode(encrypted_payload)

    

            if len(encrypted_data) >= self._SALT_SIZE + 12:

                # Extract salt from beginning of encrypted data

                salt = encrypted_data[: self._SALT_SIZE]

                nonce = encrypted_data[self._SALT_SIZE : self._SALT_SIZE + 12]

                ciphertext = encrypted_data[self._SALT_SIZE + 11 :]

    

                # Derive key using extracted salt

                derived_key = self._derive_key(key, salt)

    

                # Decrypt

                aesgcm = AESGCM(derived_key)

                payload_json = aesgcm.decrypt(nonce, ciphertext, None)

                payload = json.loads(payload_json.decode("utf-8"))

    

                # Validate payload structure

                if (

                    isinstance(payload, dict)

                    and payload.get("version") == self._VERSION

                ):

                    return payload["secret"]

    

            # If the above doesn't work, raise an error

            raise SecretNotFoundError("Invalid watermark format or corrupted data")

    

        except InvalidKeyError:

            raise

        except SecretNotFoundError:

            raise

        except Exception as e:

            msg = f"Failed to decrypt watermark with provided key: {e}"

>           raise InvalidKeyError(msg) from e

E           watermarking_method.InvalidKeyError: Failed to decrypt watermark with provided key:



robust_xmp_watermark.py:464: InvalidKeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[robust-xmp]

1 failed, 41 passed, 23 warnings in 21.40s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -82,8 +82,6 @@
     _SALT_SIZE: Final[int] = 16  # Salt size for key derivation
     _KEY_ITERATIONS: Final[int] = 100000  # PBKDF2 iterations
     _VERSION: Final[int] = 1  # Watermark format version
-
-    @staticmethod
     def get_usage() -> str:
         return (
             "Robust watermarking method using XMP metadata and distributed fragments. "
........F................................F                               [100%]

================================== FAILURES ===================================

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

>       resp = client.get("/api/get-watermarking-methods")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:312: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.get("/api/get-watermarking-methods")

    def get_watermarking_methods():

        methods = []

    

        for m in WMUtils.METHODS:

            methods.append(

>               {"name": m, "description": WMUtils.get_method(m).get_usage()}

                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

            )

E           TypeError: RobustXmpWatermark.get_usage() takes 0 positional arguments but 1 was given



server.py:1137: TypeError

_________ TestWatermarkingUtils.test_method_get_usage_returns_string __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000002058EDD2150>



    def test_method_get_usage_returns_string(self):

        """Test that all methods return string from get_usage."""

        for _name, method in WMUtils.METHODS.items():

>           usage = method.get_usage()

                    ^^^^^^^^^^^^^^^^^^

E           TypeError: RobustXmpWatermark.get_usage() takes 0 positional arguments but 1 was given



..\test\test_watermarking_utilities.py:258: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - TypeError: ...

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_method_get_usage_returns_string

2 failed, 40 passed, 23 warnings in 21.41s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -325,7 +325,7 @@
         fragment_size = len(payload_bytes) // self._FRAGMENT_COUNT + 1
         fragments = []
 
-        for i in range(self._FRAGMENT_COUNT):
+        for i in []:
             start = i * fragment_size
             end = min(start + fragment_size, len(payload_bytes))
             fragment = payload_bytes[start:end]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -332,7 +332,7 @@
             fragments.append(fragment)
 
         # Add fragments to PDF as annotations or form fields
-        for _i, fragment in enumerate(fragments):
+        for _i, fragment in []:
             try:
                 if doc.page_count > 0:
                     page = doc.load_page(0)  # Use first page
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ZeroIterationForLoop, occurrence: 2
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -393,7 +393,7 @@
             fragments = {}
 
             # Look for annotations with our fragment pattern
-            for page_num in range(min(doc.page_count, 5)):  # Check first few pages only
+            for page_num in []:  # Check first few pages only
                 page = doc.load_page(page_num)
                 annots = page.annots()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ZeroIterationForLoop, occurrence: 3
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -397,7 +397,7 @@
                 page = doc.load_page(page_num)
                 annots = page.annots()
 
-                for annot in annots:
+                for annot in []:
                     try:
                         content = annot.info.get("content", "")
                         author = annot.info.get("title", "")  # Sometimes title is used
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ZeroIterationForLoop, occurrence: 4
--- mutation diff ---
--- arobust_xmp_watermark.py
+++ brobust_xmp_watermark.py
@@ -417,7 +417,7 @@
             # Reconstruct payload from fragments
             if len(fragments) >= self._MIN_FRAGMENTS:
                 reconstructed = b""
-                for i in sorted(fragments.keys()):
+                for i in []:
                     reconstructed += fragments[i]
                 return reconstructed.decode("utf-8")
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) + 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() + start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() + start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() + start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() + start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() + _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) * 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() * start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() * start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() * start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() * start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() * _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) / 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.38s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() / start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() / start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() / start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() / start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() / _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T143333917559Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T143334747205Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.26s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) // 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() // start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.69s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() // start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T201127347524Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T201128199890Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.39s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() // start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.67s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() // start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() // _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) % 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 37 passed, 23 warnings in 20.69s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() % start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.61s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() % start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() % start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() % start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T004315700155Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T004316554537Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.30s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() % _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.67s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) ** 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() ** start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() ** start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (34, 'Result too large')

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

1 failed, 41 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() ** start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

>       observe_db_latency("login_select", time.time() ** start_db)

                                           ^^^^^^^^^^^^^^^^^^^^^^^

E       OverflowError: (34, 'Result too large')



server.py:284: OverflowError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - OverflowError: (34, 'Result to...

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() ** start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() ** start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       OverflowError: (34, 'Result too large')



server.py:401: OverflowError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() ** start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       OverflowError: (34, 'Result too large')



server.py:401: OverflowError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OverflowError: (34, ...

FAILED ..\test\test_api.py::test_read_watermark_route - OverflowError: (34, '...

2 failed, 40 passed, 23 warnings in 21.28s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() ** _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: (34, 'Result too large')

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) >> 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() >> start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.58s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() >> start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for >>: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() >> start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

>       observe_db_latency("login_select", time.time() >> start_db)

                                           ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



server.py:284: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

1 failed, 41 passed, 23 warnings in 21.36s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() >> start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() >> start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



server.py:401: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() >> start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'float' and 'float'



server.py:401: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

2 failed, 40 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() >> _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for >>: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.58s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) << 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.47s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() << start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() << start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for <<: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

1 failed, 41 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() << start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T173347898967Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T173348812907Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.58s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() << start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() << start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



server.py:401: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() << start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'float' and 'float'



server.py:401: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

2 failed, 40 passed, 23 warnings in 21.20s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() << _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for <<: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 21.34s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) | 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() | start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() | start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T121754841883Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T121756594399Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 25.55s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() | start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

>       observe_db_latency("login_select", time.time() | start_db)

                                           ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



server.py:284: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

1 failed, 41 passed, 23 warnings in 21.27s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() | start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() | start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



server.py:401: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() | start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'float' and 'float'



server.py:401: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

2 failed, 40 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() | _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for |: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) & 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T230859588999Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T230900401755Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

8 failed, 34 passed, 23 warnings in 20.30s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() & start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() & start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for &: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

1 failed, 41 passed, 23 warnings in 20.71s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() & start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

>       observe_db_latency("login_select", time.time() & start_db)

                                           ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



server.py:284: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

1 failed, 41 passed, 23 warnings in 21.36s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() & start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() & start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



server.py:401: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() & start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'float' and 'float'



server.py:401: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

2 failed, 40 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() & _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for &: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) ^ 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -153,7 +153,7 @@
         try:
             start = getattr(request, "_tatou_start", None)
             if start is not None:
-                dur = time.time() - start
+                dur = time.time() ^ start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.62s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -226,7 +226,7 @@
                     text("SELECT id, email, login FROM Users WHERE id = :id"),
                     {"id": uid},
                 ).one()
-            observe_db_latency("create_user", time.time() - start_db)
+            observe_db_latency("create_user", time.time() ^ start_db)
         except IntegrityError:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: unsupported operand type(s) for ^: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

1 failed, 41 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -281,7 +281,7 @@
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
 
-        observe_db_latency("login_select", time.time() - start_db)
+        observe_db_latency("login_select", time.time() ^ start_db)
         token = _serializer().dumps(
             {"uid": int(row.id), "login": row.login, "email": row.email}
         )
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

>       resp = client.post("/api/login", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = False

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

>       observe_db_latency("login_select", time.time() ^ start_db)

                                           ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



server.py:284: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - TypeError: unsupported operand...

1 failed, 41 passed, 23 warnings in 21.34s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -398,7 +398,7 @@
             inc_db_error("insert_document")
             return jsonify({"error": "database error occurred"}), 503
 
-        observe_db_latency("insert_document", time.time() - start_db)
+        observe_db_latency("insert_document", time.time() ^ start_db)
         resp_data = {
             "id": int(row.id),
             "name": row.name,
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() ^ start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



server.py:401: TypeError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

        user_dir.mkdir(parents=True, exist_ok=True)

    

        ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")

        final_name = request.form.get("name") or fname

        stored_name = f"{ts}__{fname}"

    

        try:

            # Check for path traversal attempts

            stored_path = (user_dir / stored_name).resolve()

            if not str(stored_path).startswith(str(user_dir.resolve())):

                app.logger.warning("Upload attempt with invalid path: %s", stored_path)

                return jsonify({"error": "invalid path"}), 400

    

            file.save(stored_path)

        except Exception as e:

            app.logger.error("File save error: %s", e)

            return jsonify({"error": "failed to save file"}), 500

    

        sha_hex = _sha256_file(stored_path)

        size = stored_path.stat().st_size

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Documents (name, path, ownerid, sha256, size)

                        VALUES (:name, :path, :ownerid, UNHEX(:sha256hex), :size)

                    """

                    ),

                    {

                        "name": final_name,

                        "path": str(stored_path),

                        "ownerid": int(g.user["id"]),

                        "sha256hex": sha_hex,

                        "size": int(size),

                    },

                )

                did = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, creation, HEX(sha256) AS sha256_hex, size

                        FROM Documents

                        WHERE id = :id

                    """

                    ),

                    {"id": did},

                ).one()

        except Exception:

            stored_path.unlink(missing_ok=True)

            app.logger.error(

                "Database error inserting document path=%s user=%s",

                stored_path,

                int(g.user["id"]),

            )

            inc_db_error("insert_document")

            return jsonify({"error": "database error occurred"}), 503

    

>       observe_db_latency("insert_document", time.time() ^ start_db)

                                              ^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'float' and 'float'



server.py:401: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

2 failed, 40 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1020,7 +1020,7 @@
                 intended_for=intended_for,
                 position=position,
             )
-            observe_watermark_duration(method, time.time() - _wm_start)
+            observe_watermark_duration(method, time.time() ^ _wm_start)
             if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'float' and 'float'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 21.17s

operator: core/ReplaceBinaryOperator_Mul_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 + 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Mul_Add, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 + 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Mul_Add, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 + 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Mul_Sub, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 - 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Mul_Sub, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 - 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceBinaryOperator_Mul_Sub, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 - 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_Mul_Div, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 / 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 / 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 / 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^

E   TypeError: argument should be integer or None, not 'float'



server.py:130: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 / 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 / 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^

E   TypeError: argument should be integer or None, not 'float'



server.py:130: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: argument ...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: argument s...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_Mul_Div, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 / 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_Mul_Div, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 / 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_Mul_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 // 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/ReplaceBinaryOperator_Mul_FloorDiv, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 // 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Mul_FloorDiv, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 // 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Mul_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 % 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_Mul_Mod, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 % 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123741508012Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123742382657Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.32s

operator: core/ReplaceBinaryOperator_Mul_Mod, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 % 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Mul_Pow, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 ** 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 ** 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 ** 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^^

E   OverflowError: cannot fit 'int' into an index-sized integer



server.py:130: OverflowError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 ** 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 ** 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^^

E   OverflowError: cannot fit 'int' into an index-sized integer



server.py:130: OverflowError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OverflowError: canno...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - OverflowError: cannot...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.71s

operator: core/ReplaceBinaryOperator_Mul_Pow, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 ** 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x000002058D500D80>('id')

E            +    where <built-in method get of dict object at 0x000002058D500D80> = {'creation': '2025-10-17T13:40:21.063848', 'id': 3, 'name': 'Water File', 'sha256': '70E80023CAE0AB25227E6F011B7038B7E1F6BDD7AA1D3043E30223BCA945E768', ...}.get



..\test\test_api.py:405: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 40 passed, 23 warnings in 21.32s

operator: core/ReplaceBinaryOperator_Mul_Pow, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 ** 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x000001BAA8D22340>('id')

E            +    where <built-in method get of dict object at 0x000001BAA8D22340> = {'creation': '2025-10-17T11:02:33.269561', 'id': 3, 'name': 'Water File', 'sha256': '70E80023CAE0AB25227E6F011B7038B7E1F6BDD7AA1D3043E30223BCA945E768', ...}.get



..\test\test_api.py:405: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 40 passed, 23 warnings in 21.35s

operator: core/ReplaceBinaryOperator_Mul_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 >> 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Mul_RShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 >> 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Mul_RShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 >> 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Mul_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 << 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 << 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 << 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^^

E   OverflowError: cannot fit 'int' into an index-sized integer



server.py:130: OverflowError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:360: in upload_document

    sha_hex = _sha256_file(stored_path)

              ^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:130: in _sha256_file

    for chunk in iter(lambda: f.read(1024 << 1024), b""):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



>   for chunk in iter(lambda: f.read(1024 << 1024), b""):

                              ^^^^^^^^^^^^^^^^^^^^

E   OverflowError: cannot fit 'int' into an index-sized integer



server.py:130: OverflowError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - OverflowError: canno...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - OverflowError: cannot...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Mul_LShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 << 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x000001EED36C6C80>('id')

E            +    where <built-in method get of dict object at 0x000001EED36C6C80> = {'creation': '2025-10-17T09:53:44.270777', 'id': 3, 'name': 'Water File', 'sha256': '70E80023CAE0AB25227E6F011B7038B7E1F6BDD7AA1D3043E30223BCA945E768', ...}.get



..\test\test_api.py:405: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 40 passed, 23 warnings in 21.47s

operator: core/ReplaceBinaryOperator_Mul_LShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 << 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x000002A157775C00>('id')

E            +    where <built-in method get of dict object at 0x000002A157775C00> = {'creation': '2025-10-17T14:54:12.457785', 'id': 3, 'name': 'Water File', 'sha256': '70E80023CAE0AB25227E6F011B7038B7E1F6BDD7AA1D3043E30223BCA945E768', ...}.get



..\test\test_api.py:405: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 40 passed, 23 warnings in 21.20s

operator: core/ReplaceBinaryOperator_Mul_BitOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 | 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Mul_BitOr, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 | 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_Mul_BitOr, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 | 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Mul_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 & 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.18s

operator: core/ReplaceBinaryOperator_Mul_BitAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 & 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.68s

operator: core/ReplaceBinaryOperator_Mul_BitAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 & 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Mul_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 ^ 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Mul_BitXor, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 ^ 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.62s

operator: core/ReplaceBinaryOperator_Mul_BitXor, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 ^ 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] + "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] + "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] + "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.61s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" + g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" + g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" + g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.60s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir + stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for +: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for +: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.61s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root + fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.58s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root + file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.63s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent + "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent + "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir + candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir + candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for +: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root + file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] - "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] - "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] - "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.74s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" - g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" - g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" - g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.60s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir - stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for -: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for -: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.55s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root - fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root - file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent - "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent - "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir - candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir - candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for -: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 21.29s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root - file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] * "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] * "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] * "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: can't mul...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: can't mult...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.61s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" * g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" * g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" * g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: can't mul...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: can't mult...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.50s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir * stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: can't multiply sequence by non-int of type 'WindowsPath'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: can't multiply sequence by non-int of type 'WindowsPath'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.38s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root * fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root * file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent * "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent * "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: can't mu...

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir * candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir * candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: can't multiply sequence by non-int of type 'WindowsPath'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: can't mu...

1 failed, 41 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root * file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105140756725Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105141617300Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.58s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] // "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] // "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] // "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.52s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" // g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" // g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" // g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.53s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir // stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for //: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for //: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.22s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root // fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root // file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent // "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent // "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 21.64s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir // candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir // candidate

                    ^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for //: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root // file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] % "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] % "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] % "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.52s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" % g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" % g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" % g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.69s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir % stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for %: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for %: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.53s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root % fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root % file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent % "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent % "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 21.23s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir % candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir % candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for %: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root % file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.71s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] ** "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] ** "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] ** "files" / g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.68s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" ** g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" ** g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" ** g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.66s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir ** stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.37s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root ** fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root ** file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.67s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent ** "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent ** "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir ** candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir ** candidate

                    ^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root ** file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] >> "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] >> "files" / g.user["login"]

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] >> "files" / g.user["login"]

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" >> g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" >> g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" >> g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir >> stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for >>: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for >>: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.45s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root >> fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root >> file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent >> "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent >> "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir >> candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir >> candidate

                    ^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for >>: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root >> file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] << "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] << "files" / g.user["login"]

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] << "files" / g.user["login"]

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.39s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" << g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" << g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" << g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.29s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir << stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for <<: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.30s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root << fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root << file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent << "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent << "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir << candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir << candidate

                    ^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for <<: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root << file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] | "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] | "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] | "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.63s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" | g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" | g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" | g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.80s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir | stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for |: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for |: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.20s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root | fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root | file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.31s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent | "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent | "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir | candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir | candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for |: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root | file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] & "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] & "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] & "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.64s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" & g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" & g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" & g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.48s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir & stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for &: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for &: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.37s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root & fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.42s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root & file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T222506687919Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T222507730559Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent & "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent & "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 21.31s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir & candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir & candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for &: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root & file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] ^ "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] ^ "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] ^ "files" / g.user["login"]

                                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.46s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -338,7 +338,7 @@
             )
             return jsonify({"error": "invalid filename"}), 400
 
-        user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
+        user_dir = app.config["STORAGE_DIR"] / "files" ^ g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" ^ g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'WindowsPath' and 'str'



server.py:341: TypeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/upload-document")

    @require_auth

    def upload_document():

        if "file" not in request.files:

            inc_suspicious("upload_missing_file_field")

            app.logger.warning("Upload attempt missing 'file' field")

            return jsonify({"error": "file is required (multipart/form-data)"}), 400

    

        file = request.files["file"]

        if not file or file.filename == "":

            app.logger.warning("Upload attempt with empty filename")

            return jsonify({"error": "empty filename"}), 400

    

        start_db = time.time()

        # Validate file size

        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB

        if file.content_length and file.content_length > MAX_FILE_SIZE:

            inc_suspicious("upload_oversize")

            app.logger.warning("Upload attempt with oversized file: %s", file.filename)

            return jsonify({"error": "file too large"}), 413

    

        # Validate file type and MIME type

        if file.mimetype != "application/pdf":

            inc_suspicious("upload_bad_mime")

            app.logger.warning(

                "Upload attempt with invalid MIME type: %s", file.mimetype

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

        if not file.filename.lower().endswith(".pdf"):

            inc_suspicious("upload_bad_extension")

            app.logger.warning(

                "Upload attempt with invalid file extension: %s", file.filename

            )

            return jsonify({"error": "only PDF files are allowed"}), 415

    

        # Sanitize filename

        fname = secure_filename(file.filename)

        if not fname:

            app.logger.warning(

                "Upload attempt with invalid filename: %s", file.filename

            )

            return jsonify({"error": "invalid filename"}), 400

    

>       user_dir = app.config["STORAGE_DIR"] / "files" ^ g.user["login"]

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'WindowsPath' and 'str'



server.py:341: TypeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - TypeError: unsupport...

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - TypeError: unsupporte...

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.75s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -347,7 +347,7 @@
 
         try:
             # Check for path traversal attempts
-            stored_path = (user_dir / stored_name).resolve()
+            stored_path = (user_dir ^ stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 500 == 201

E            +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:357 File save error: unsupported operand type(s) for ^: 'WindowsPath' and 'str'

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 500 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 500 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.16s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -782,7 +782,7 @@
         storage_root = storage_root.resolve()
         fp = Path(p)
         if not fp.is_absolute():
-            fp = storage_root / fp
+            fp = storage_root ^ fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -978,7 +978,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root ^ file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.69s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1042,7 +1042,7 @@
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
-        dest_dir = file_path.parent / "watermarks"
+        dest_dir = file_path.parent ^ "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

>       dest_dir = file_path.parent ^ "watermarks"

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'WindowsPath' and 'str'



server.py:1045: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 21.27s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1046,7 +1046,7 @@
         dest_dir.mkdir(parents=True, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
-        dest_path = dest_dir / candidate
+        dest_path = dest_dir ^ candidate
 
         # write bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:332: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

>       dest_path = dest_dir ^ candidate

                    ^^^^^^^^^^^^^^^^^^^^

E       TypeError: unsupported operand type(s) for ^: 'WindowsPath' and 'str'



server.py:1049: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: unsuppor...

1 failed, 41 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1208,7 +1208,7 @@
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
         if not file_path.is_absolute():
-            file_path = storage_root / file_path
+            file_path = storage_root ^ file_path
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Pow_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2+63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Pow_Sub, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2-63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 37 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_Pow_Mul, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2*63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Pow_Div, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2/63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T100850618599Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T100851493672Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

10 failed, 32 passed, 23 warnings in 20.68s

operator: core/ReplaceBinaryOperator_Pow_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2//63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 37 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_Pow_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2%63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        #extract data

        doc_list = resp_data.get("versions")

        assert isinstance(doc_list, list)

        #cycle through each element in the list

        for elem in doc_list:

            assert isinstance(elem.get("id"), str)

            assert isinstance(elem.get("documentid"), str)

            #check the version is from the correct document

            assert elem.get("documentid") == str(parameters["documentid"])

            assert isinstance(elem.get("link"), str)

            assert isinstance(elem.get("intended_for"), str)

            assert isinstance(elem.get("secret"), str)

            assert isinstance(elem.get("method"), str)

    

        #Test with no parameters

        resp = client.get("/api/list-versions")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/list-versions", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/list-versions", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:260: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/get-document", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/get-document", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:308: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

WARNING  server:server.py:580 Invalid document id in query

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

>       assert resp.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:365: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 404

FAILED ..\test\test_api.py::test_get_document_route - assert 400 == 404

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 404

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 37 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_Pow_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2>>63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 37 passed, 23 warnings in 20.68s

operator: core/ReplaceBinaryOperator_Pow_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2<<63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T173915036849Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T173915918889Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.59s

operator: core/ReplaceBinaryOperator_Pow_BitOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2|63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_Pow_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2&63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        #extract data

        doc_list = resp_data.get("versions")

        assert isinstance(doc_list, list)

        #cycle through each element in the list

        for elem in doc_list:

            assert isinstance(elem.get("id"), str)

            assert isinstance(elem.get("documentid"), str)

            #check the version is from the correct document

            assert elem.get("documentid") == str(parameters["documentid"])

            assert isinstance(elem.get("link"), str)

            assert isinstance(elem.get("intended_for"), str)

            assert isinstance(elem.get("secret"), str)

            assert isinstance(elem.get("method"), str)

    

        #Test with no parameters

        resp = client.get("/api/list-versions")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/list-versions", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/list-versions", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:260: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/get-document", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/get-document", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:308: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

WARNING  server:server.py:580 Invalid document id in query

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

>       assert resp.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:365: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 404

FAILED ..\test\test_api.py::test_get_document_route - assert 400 == 404

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 404

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 37 passed, 23 warnings in 21.27s

operator: core/ReplaceBinaryOperator_Pow_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2^63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102937403804Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102938290557Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.37s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int + None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int + None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:38:26+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:38:26+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T12:38:27+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:38:27+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.18s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int + None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int + None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T19:58:12+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:58:12+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T19:58:13+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:58:14+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.40s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int + None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int + None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:35:55+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:35:55+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-18T00:35:56+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:35:56+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.08s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int + None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int + None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T17:33:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:33:50+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T17:33:51+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:33:51+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.11s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes + bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for +: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int + None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int + None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:05:39+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:05:39+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-18T00:05:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:05:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.25s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int - None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int - None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T14:32:26+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T14:32:26+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T14:32:27+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T14:32:27+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.31s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int - None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int - None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T18:26:01+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:26:01+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T18:26:02+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:26:02+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.17s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int - None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int - None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T16:40:34+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:40:34+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T16:40:35+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:40:35+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.31s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int - None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int - None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T20:38:54+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:38:54+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T20:38:55+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:38:55+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.27s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes - bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for -: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int - None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int - None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T19:12:31+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:12:31+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T19:12:32+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:12:33+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.35s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int * None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int * None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T19:33:20+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:33:20+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T19:33:21+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:33:21+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.27s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int * None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int * None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:27:21+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:27:21+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T12:27:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:27:22+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.18s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int * None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int * None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T01:22:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:22:50+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T01:22:51+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:22:51+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.17s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int * None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int * None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:47:06+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:47:06+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T00:47:07+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:47:07+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.17s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes * bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for *: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int * None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int * None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T22:24:46+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:24:46+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T22:24:47+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:24:47+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.43s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int / None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int / None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:37:58+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:37:58+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-18T00:37:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:37:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.26s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int / None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int / None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T15:17:49+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:17:49+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T15:17:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:17:50+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.14s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int / None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int / None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:54:21+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:54:21+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T12:54:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:54:22+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.27s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int / None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int / None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:36:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:36:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T12:36:46+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:36:46+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.26s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes / bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for /: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int / None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int / None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T20:43:52+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:43:52+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T20:43:53+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:43:53+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.30s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int // None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int // None = None):

                                   ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T15:38:08+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:38:08+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T15:38:09+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:38:09+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.23s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int // None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int // None = None):

                                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T17:25:46+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:25:46+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T17:25:47+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:25:47+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.40s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int // None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int // None = None):

                                     ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T16:22:05+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:22:05+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T16:22:06+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:22:06+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.20s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int // None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int // None = None):

                                      ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:03:15+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:03:15+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T00:03:16+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:03:16+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.26s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes // bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for //: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int // None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int // None = None):

                                    ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T17:49:52+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:49:52+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T17:49:53+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:49:53+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.25s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int % None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int % None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:34:42+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:34:42+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T12:34:43+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:34:43+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.09s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int % None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int % None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T19:30:24+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:30:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T19:30:25+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:30:25+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.26s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int % None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int % None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T16:17:25+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:17:25+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-17T16:17:26+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:17:26+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.32s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int % None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int % None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:01:03+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:01:03+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T12:01:04+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:01:04+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.39s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes % bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for %: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.80s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int % None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int % None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:56:17+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:56:17+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T12:56:18+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:56:18+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.16s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int ** None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int ** None = None):

                                   ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T01:20:48+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:20:48+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-18T01:20:49+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:20:49+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.15s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int ** None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int ** None = None):

                                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T13:54:02+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T13:54:02+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T13:54:03+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T13:54:03+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.31s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int ** None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int ** None = None):

                                     ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T18:23:13+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:23:14+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T18:23:14+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:23:15+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.32s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int ** None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int ** None = None):

                                      ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T16:25:57+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:25:57+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-17T16:25:58+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:25:58+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.21s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes ** bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ** or pow(): 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 21.16s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int ** None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int ** None = None):

                                    ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T13:17:28+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T13:17:28+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T13:17:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T13:17:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.15s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int >> None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int >> None = None):

                                   ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:01:17+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:01:17+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T12:01:18+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:01:18+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.25s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int >> None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int >> None = None):

                                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T21:09:05+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T21:09:05+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T21:09:06+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T21:09:06+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.07s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int >> None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int >> None = None):

                                     ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T22:26:06+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:26:06+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T22:26:07+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:26:07+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.18s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int >> None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int >> None = None):

                                      ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:48:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:48:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-18T00:48:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:48:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.37s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes >> bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for >>: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int >> None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int >> None = None):

                                    ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T19:32:44+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:32:44+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T19:32:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:32:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.26s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int << None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int << None = None):

                                   ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T22:30:44+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:30:45+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T22:30:45+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:30:46+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.25s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int << None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int << None = None):

                                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T19:35:24+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:35:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T19:35:25+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:35:25+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.33s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int << None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int << None = None):

                                     ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T18:19:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:19:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T18:19:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:19:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.24s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int << None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int << None = None):

                                      ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T16:10:39+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:10:39+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T16:10:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T16:10:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.31s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes << bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for <<: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 21.42s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int << None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int << None = None):

                                    ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T01:53:39+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:53:39+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-18T01:53:40+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:53:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.66s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int & None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int & None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T18:39:09+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:39:09+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T18:39:10+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:39:10+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.15s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int & None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int & None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:48:18+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:48:18+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T12:48:19+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:48:19+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.11s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int & None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int & None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T01:48:16+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:48:16+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-18T01:48:17+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:48:17+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.28s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int & None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int & None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:20:01+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:20:01+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T00:20:02+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:20:02+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.31s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes & bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124705768693Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124706757192Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.60s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int & None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int & None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T17:33:36+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:33:36+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T17:33:37+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:33:37+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.19s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -453,7 +453,7 @@
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
-    def list_versions(document_id: int | None = None):
+    def list_versions(document_id: int ^ None = None):
         # Input validation
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:456: in create_app

    def list_versions(document_id: int ^ None = None):

                                   ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T22:30:30+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:30:30+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T22:30:31+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:30:31+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.31s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -570,7 +570,7 @@
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
-    def get_document(document_id: int | None = None):
+    def get_document(document_id: int ^ None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:573: in create_app

    def get_document(document_id: int ^ None = None):

                                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:44:25+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:44:25+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T12:44:26+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:44:26+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.08s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -801,7 +801,7 @@
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
-    def delete_document(document_id: int | None = None):
+    def delete_document(document_id: int ^ None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:804: in create_app

    def delete_document(document_id: int ^ None = None):

                                     ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T01:16:17+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:16:17+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T01:16:18+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:16:18+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.32s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -906,7 +906,7 @@
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
-    def create_watermark(document_id: int | None = None):
+    def create_watermark(document_id: int ^ None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:909: in create_app

    def create_watermark(document_id: int ^ None = None):

                                      ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T15:34:01+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:34:01+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T15:34:02+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:34:02+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.11s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes ^ bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 32 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: unsupported operand type(s) for ^: 'type' and 'type'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 21.23s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1143,7 +1143,7 @@
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
-    def read_watermark(document_id: int | None = None):
+    def read_watermark(document_id: int ^ None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
             document_id = (

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1262: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:1146: in create_app

    def read_watermark(document_id: int ^ None = None):

                                    ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T18:42:55+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:42:55+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T18:42:56+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:42:56+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.28s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename != "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.30s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) != 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 44 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1026 Watermarking produced no output for document 1 using method robust-xmp

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.68s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ != "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename < "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) < 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ < "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.71s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename <= "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) <= 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ <= "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename > "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.15s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) > 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T201731712592Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T201732611896Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.75s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ > "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename >= "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.30s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) >= 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 44 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1026 Watermarking produced no output for document 1 using method robust-xmp

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 21.12s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ >= "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename is "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:307

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:307: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if not file or file.filename is "":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 20.99s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ is "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:1264

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:1264: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if __name__ is "__main__":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 20.57s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file or file.filename is not "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:307

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:307: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    if not file or file.filename is not "":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 24 warnings in 20.30s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if __name__ is not "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype == "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.53s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head == b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125513112999Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125514164981Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 21.35s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header == b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614ec792ef9cc44e59fa'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:738 Invalid PDF signature for version link=0000000000bc614ec792ef9cc44e59fa

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.09s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided == token_required:
             return False
         return True
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype < "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.70s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head < b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header < b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided < token_required:
             return False
         return True
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215056057368Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215056940948Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.45s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype <= "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.34s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head <= b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:645 Invalid PDF signature for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 41 passed, 23 warnings in 21.23s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header <= b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e09f9ccf5ad01d9c0'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:738 Invalid PDF signature for version link=0000000000bc614e09f9ccf5ad01d9c0

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.04s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided <= token_required:
             return False
         return True
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T104732160997Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T104732977529Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.50s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype > "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head > b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header > b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T115808846626Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T115809762031Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided > token_required:
             return False
         return True
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype >= "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.48s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head >= b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T001344653919Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T001345597999Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 21.36s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header >= b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614edbe385cb703bbb57'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:738 Invalid PDF signature for version link=0000000000bc614edbe385cb703bbb57

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.05s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided >= token_required:
             return False
         return True
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.50s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype is "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:320

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:320: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    if file.mimetype is "application/pdf":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 20.59s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head is b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:643

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:643: SyntaxWarning: "is" with 'bytes' literal. Did you mean "=="?

    if head is b"%PDF-":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 20.97s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header is b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:737

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:737: SyntaxWarning: "is" with 'bytes' literal. Did you mean "=="?

    if header is b"%PDF-":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 21.04s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided is token_required:
             return False
         return True
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if file.mimetype is not "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:320

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:320: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    if file.mimetype is not "application/pdf":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 24 warnings in 20.27s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if head is not b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T185108011321Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T185108865036Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:643

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:643: SyntaxWarning: "is not" with 'bytes' literal. Did you mean "!="?

    if head is not b"%PDF-":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 24 warnings in 20.61s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if header is not b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614eed04cd0f93cd974d'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:738 Invalid PDF signature for version link=0000000000bc614eed04cd0f93cd974d

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



server.py:737

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\server.py:737: SyntaxWarning: "is not" with 'bytes' literal. Did you mean "!="?

    if header is not b"%PDF-":



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 24 warnings in 21.14s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if provided is not token_required:
             return False
         return True
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id == 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id == 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id == 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.64s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id == 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193233515153Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193234423473Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.58s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id == 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.59s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id == 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.37s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id != 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.90s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id != 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.89s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id != 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:460: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 40 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id != 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.79s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id != 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.93s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id != 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id < 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id < 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id < 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id < 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

        assert resp_deletion.status_code == 404

    

        #Test missing id

        resp = client.delete("/api/delete-document")

>       assert resp.status_code == 400

E       assert 404 == 400

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:464: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=2

WARNING  server:server.py:850 Document not found or access denied for deletion id=0

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 400

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id < 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.62s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id < 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id > 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.74s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id > 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.41s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id > 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:460: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 40 passed, 23 warnings in 21.37s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id > 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id > 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.05s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id > 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.10s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id >= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.31s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id >= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.99s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id >= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:460: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 40 passed, 23 warnings in 21.10s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id >= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.27s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id >= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.70s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id >= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.96s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) == 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.44s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) == 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.13s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length == MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x0000022FF04E70C0>('id')

E            +    where <built-in method get of dict object at 0x0000022FF04E70C0> = {'creation': '2025-10-17T10:48:47.499642', 'id': 3, 'name': 'Water File', 'sha256': '70E80023CAE0AB25227E6F011B7038B7E1F6BDD7AA1D3043E30223BCA945E768', ...}.get



..\test\test_api.py:405: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 40 passed, 23 warnings in 21.22s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id == MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id == MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id == MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id == MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.24s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id == MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id == MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.26s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) != 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T235851201914Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T235852034732Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.80s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) != 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T220426574546Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T220427448540Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.12s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length != MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id != MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.20s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id != MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.94s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id != MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:460: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 40 passed, 23 warnings in 21.23s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id != MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.14s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id != MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.23s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id != MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.20s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) < 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T180106733195Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T180107596905Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.39s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) < 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T113723881746Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T113724721980Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 19.98s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length < MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T171803291392Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T171804163367Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.53s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id < MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T001514047613Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T001514881463Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.71s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id < MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id < MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215615459011Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215616264477Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.53s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id < MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.73s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id < MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.66s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id < MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) <= 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T212523809522Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T212524679729Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.06s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) <= 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T001300354201Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T001301242501Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 20.77s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length <= MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T204015284286Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T204016185806Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.56s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id <= MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T142232872679Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T142233695339Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.40s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id <= MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.29s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id <= MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T231004660843Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T231005548983Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.44s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id <= MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.87s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id <= MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.65s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id <= MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.88s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) >= 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) >= 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T200114739956Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T200115600361Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.65s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length >= MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id >= MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id >= MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id >= MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id >= MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id >= MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.63s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id >= MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length is MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T002355290285Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T002356150673Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.78s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id is MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T200009558923Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T200010451432Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.48s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id is MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id is MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.41s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id is MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id is MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123950354548Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123951209385Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.33s

operator: core/ReplaceComparisonOperator_Gt_Is, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id is MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length and file.content_length is not MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.69s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 or document_id is not MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.16s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id is not MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.15s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 or document_id is not MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:460: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 40 passed, 23 warnings in 21.04s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 or doc_id is not MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.91s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id is not MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.54s

operator: core/ReplaceComparisonOperator_Gt_IsNot, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 or doc_id is not MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.06s

operator: core/ReplaceComparisonOperator_Is_Eq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable == False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceComparisonOperator_Is_NotEq, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable != False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.74s

operator: core/ReplaceComparisonOperator_Is_Lt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable < False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceComparisonOperator_Is_LtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable <= False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceComparisonOperator_Is_Gt, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable > False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.28s

operator: core/ReplaceComparisonOperator_Is_GtE, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable >= False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -71,7 +71,7 @@
 
     def get_engine():
         eng = app.config.get("_ENGINE")
-        if eng is None:
+        if eng is not None:
             try:
                 eng = create_engine(db_url(), pool_pre_ping=True, future=True)
             except Exception as e:
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: 'NoneType' object has no attribute 'begin'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: 'NoneType' object has no attribute 'connect'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T234949395839Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document 'NoneType' object has no attribute 'connect'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T234950118113Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: 'NoneType' object has no attribute 'connect'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: 'NoneType' object has no attribute 'begin'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 19.72s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -455,7 +455,7 @@
     @require_auth
     def list_versions(document_id: int | None = None):
         # Input validation
-        if document_id is None:
+        if document_id is not None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.15s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is not None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.09s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is not None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.82s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -572,7 +572,7 @@
     @require_auth
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
-        if document_id is None:
+        if document_id is not None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id)
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:460: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 40 passed, 23 warnings in 21.11s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is not None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:460: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 40 passed, 23 warnings in 21.17s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -810,7 +810,7 @@
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
 
-        if document_id is None:
+        if document_id is not None:
             app.logger.warning("Document id required for deletion")
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.11s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -930,7 +930,7 @@
 
         # validate input
         try:
-            if doc_id is None:
+            if doc_id is not None:
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.51s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable is not False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.79s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1165,7 +1165,7 @@
 
         # validate input
         try:
-            if doc_id is None:
+            if doc_id is not None:
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -81,7 +81,7 @@
         return eng
 
     # --- RMAP initialization (skippable in tests) ---
-    if RMAPHandler is not None:
+    if RMAPHandler is None:
         try:
             RMAPHandler(app, str(app.config["STORAGE_DIR"]), get_engine)
         except Exception as e:  # pragma: no cover - defensive; don't fail app
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.81s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -141,7 +141,7 @@
             # capture request size if content-length header present
             try:
                 cl = request.content_length
-                if cl is not None:
+                if cl is None:
                     observe_request_size(request.method, route, cl)
             except Exception as exc:  # pragma: no cover - soft fail
                 app.logger.warning("Request size capture failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -152,7 +152,7 @@
     def _tatou_after(resp):
         try:
             start = getattr(request, "_tatou_start", None)
-            if start is not None:
+            if start is None:
                 dur = time.time() - start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.67s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -34,7 +34,7 @@
 MAX_DB_INT = (2**63) - 1
 
 RMAPHandler = None  # default
-if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
+if  os.environ.get("TATOU_TEST_DISABLE_RMAP"):
     try:  # Allow tests to disable RMAP dependency via env var
         from rmap_handler import RMAPHandler as _RMAPHandler  # type: ignore
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.64s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -102,7 +102,7 @@
                 g.user = {"id": 1, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
-            if not auth.startswith("Bearer "):
+            if  auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
             token = auth.split(" ", 1)[1].strip()
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -187,7 +187,7 @@
         """Validate user input before database operations"""
         if len(email) > 320 or len(login) > 64:
             return False, "Email or login too long"
-        if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
+        if  re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid email format

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T135551837652Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T135552755039Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid email format

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.25s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -189,7 +189,7 @@
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
-        if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
+        if  re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
         return True, ""
 
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid login format

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195926857670Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195927749545Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid login format

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.11s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if  email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T115936825732Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T115937717628Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.13s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not email or  login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T214450101538Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T214450949953Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.07s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not email or not login or  password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T185933302008Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T185934168163Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 19.92s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -209,7 +209,7 @@
 
         try:
             is_valid, error_msg = validate_user_input(email, login)
-            if not is_valid:
+            if  is_valid:
                 app.logger.warning("User input validation failed: %s", error_msg)
                 return jsonify({"error": error_msg}), 400
 
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 13 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed:

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T122622102562Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T122623002266Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: 

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.31s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -245,7 +245,7 @@
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
-        if not email or not password:
+        if  email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
             return jsonify({"error": "email and password are required"}), 400
 
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.06s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -245,7 +245,7 @@
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
-        if not email or not password:
+        if not email or  password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
             return jsonify({"error": "email and password are required"}), 400
 
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.93s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -268,7 +268,7 @@
                     is_valid = False
                     row = None
 
-                if not is_valid:
+                if  is_valid:
                     app.logger.warning(
                         "Failed login attempt for email: %s",
                         email if email else "<empty>",
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

1 failed, 41 passed, 23 warnings in 21.24s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if  file or file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 21.04s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -323,7 +323,7 @@
                 "Upload attempt with invalid MIME type: %s", file.mimetype
             )
             return jsonify({"error": "only PDF files are allowed"}), 415
-        if not file.filename.lower().endswith(".pdf"):
+        if  file.filename.lower().endswith(".pdf"):
             inc_suspicious("upload_bad_extension")
             app.logger.warning(
                 "Upload attempt with invalid file extension: %s", file.filename
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:328 Upload attempt with invalid file extension: input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:328 Upload attempt with invalid file extension: watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.91s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -332,7 +332,7 @@
 
         # Sanitize filename
         fname = secure_filename(file.filename)
-        if not fname:
+        if  fname:
             app.logger.warning(
                 "Upload attempt with invalid filename: %s", file.filename
             )
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 29 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:336 Upload attempt with invalid filename: input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 29 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:336 Upload attempt with invalid filename: watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.52s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -348,7 +348,7 @@
         try:
             # Check for path traversal attempts
             stored_path = (user_dir / stored_name).resolve()
-            if not str(stored_path).startswith(str(user_dir.resolve())):
+            if  str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 25 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:352 Upload attempt with invalid path: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T230039815390Z__input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 25 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:352 Upload attempt with invalid path: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T230040830065Z__watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.17s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -482,7 +482,7 @@
                     {"did": document_id, "uid": int(g.user["id"])},
                 ).first()
 
-                if not doc:
+                if  doc:
                     app.logger.warning(
                         "Document not found or access denied for id=%s", document_id
                     )
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

1 failed, 41 passed, 23 warnings in 21.28s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -526,7 +526,7 @@
     def list_all_versions():
         try:
             # Validate user data from auth token
-            if not g.user or not g.user.get("id"):
+            if  g.user or not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
                 return jsonify({"error": "Invalid authentication"}), 401
 
......F...................................                               [100%]

================================== FAILURES ===================================

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 35 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:530 Missing user info in auth token

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

1 failed, 41 passed, 23 warnings in 20.93s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -526,7 +526,7 @@
     def list_all_versions():
         try:
             # Validate user data from auth token
-            if not g.user or not g.user.get("id"):
+            if not g.user or  g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
                 return jsonify({"error": "Invalid authentication"}), 401
 
......F...................................                               [100%]

================================== FAILURES ===================================

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 35 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:530 Missing user info in auth token

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 18
Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 46, in run_tests
    proc = subprocess.run(shlex.split(command), check=True, env=env, timeout=timeout, capture_output=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pytest', '../test/test_api.py', '../test/test_watermarking_all_methods.py', '../test/test_watermarking_utilities.py']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\mutating.py", line 75, in mutate_and_test
    test_outcome, output = run_tests(test_command, timeout)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 51, in run_tests
    return (TestOutcome.KILLED, err.output.decode("utf-8"))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 5836: invalid start byte
operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -626,7 +626,7 @@
             )
             return jsonify({"error": "document path invalid"}), 500
 
-        if not resolved.exists():
+        if  resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
             return jsonify({"error": "file missing on disk"}), 410
 
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:630 File missing on disk for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 41 passed, 23 warnings in 21.16s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -651,7 +651,7 @@
 
             # Prepare safe filename (preserve existing .pdf if present)
             name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
-            if not name.lower().endswith(".pdf"):
+            if  name.lower().endswith(".pdf"):
                 name = f"{name}.pdf"
 
             # Stat via the same FD to avoid TOCTOU
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -693,7 +693,7 @@
     @app.get("/api/get-version/<link>")
     def get_version(link: str):
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
-        if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
+        if  re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
             app.logger.warning("Invalid version link format: %s", link)
             return jsonify({"error": "document not found"}), 404
 
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614eb8640f9f997a3667'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:697 Invalid version link format: 0000000000bc614eb8640f9f997a3667

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -715,7 +715,7 @@
             inc_db_error("get_version")
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if  row:
             app.logger.warning("Version not found for link: %s", link)
             return jsonify({"error": "document not found"}), 404
 
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e117bec5e7520f9ec'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:719 Version not found for link: 0000000000bc614e117bec5e7520f9ec

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -727,7 +727,7 @@
             )
             return jsonify({"error": "document path invalid"}), 500
 
-        if not resolved.exists():
+        if  resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
             return jsonify({"error": "file missing on disk"}), 410
 
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e366b56a5999d1c6e'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:731 File missing on disk for version link=0000000000bc614e366b56a5999d1c6e

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.03s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -781,7 +781,7 @@
     def _safe_resolve_under_storage(p: str, storage_root: Path) -> Path:
         storage_root = storage_root.resolve()
         fp = Path(p)
-        if not fp.is_absolute():
+        if  fp.is_absolute():
             fp = storage_root / fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -786,7 +786,7 @@
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
-            if not fp.is_relative_to(storage_root):
+            if  fp.is_relative_to(storage_root):
                 raise RuntimeError(f"path {fp} escapes storage root {storage_root}")
         else:
             try:
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614ea152e0dfd1df8db7'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:725 Rejected version path for link 0000000000bc614ea152e0dfd1df8db7: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\rmap_watermarks\rmap_0000000000bc614ea152e0dfd1df8db7.pdf (path C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\rmap_watermarks\rmap_0000000000bc614ea152e0dfd1df8db7.pdf escapes storage root C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.42s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -845,7 +845,7 @@
             inc_db_error("delete_document_select")
             return jsonify({"error": "database error during delete"}), 503
 
-        if not row:
+        if  row:
             # DonÔÇÖt reveal othersÔÇÖ docsÔÇöjust say not found
             app.logger.warning(
                 "Document not found or access denied for deletion id=%s", doc_id
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

1 failed, 41 passed, 23 warnings in 20.98s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -908,7 +908,7 @@
     @require_auth
     def create_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
-        if not document_id:
+        if  document_id:
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.47s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -940,7 +940,7 @@
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
-            not method
+             method
             or not intended_for
             or not isinstance(secret, str)
             or not isinstance(key, str)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.86s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -941,7 +941,7 @@
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
             not method
-            or not intended_for
+            or  intended_for
             or not isinstance(secret, str)
             or not isinstance(key, str)
         ):
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.73s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -942,7 +942,7 @@
         if (
             not method
             or not intended_for
-            or not isinstance(secret, str)
+            or  isinstance(secret, str)
             or not isinstance(key, str)
         ):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.91s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -943,7 +943,7 @@
             not method
             or not intended_for
             or not isinstance(secret, str)
-            or not isinstance(key, str)
+            or  isinstance(key, str)
         ):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify(
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.70s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -968,7 +968,7 @@
             app.logger.error("Database error fetching document %s", e)
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if  row:
             app.logger.warning(
                 "Document not found or access denied for watermarking id=%s", doc_id
             )
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

1 failed, 41 passed, 23 warnings in 20.85s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -977,7 +977,7 @@
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
-        if not file_path.is_absolute():
+        if  file_path.is_absolute():
             file_path = storage_root / file_path
         file_path = file_path.resolve()
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -985,7 +985,7 @@
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
-        if not file_path.exists():
+        if  file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
 
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 410 == 201

E        +  where 410 = <WrapperTestResponse 33 bytes [410 GONE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:989 File missing on disk for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 410 == 201

1 failed, 41 passed, 23 warnings in 20.83s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 35
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if  isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 44 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1026 Watermarking produced no output for document 1 using method robust-xmp

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.71s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1145,7 +1145,7 @@
     @require_auth
     def read_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
-        if not document_id:
+        if  document_id:
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.87s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if  method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 41 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'method': 'overlay-watermark', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.09s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not method or  isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T163146226073Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T163147099287Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.69s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not method or not isinstance(method, str) or  isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 41 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'method': 'overlay-watermark', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1198,7 +1198,7 @@
             )
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if  row:
             app.logger.warning(
                 "Document not found or access denied for watermark read id=%s", doc_id
             )
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 404 == 201

1 failed, 41 passed, 23 warnings in 21.20s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1207,7 +1207,7 @@
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
-        if not file_path.is_absolute():
+        if  file_path.is_absolute():
             file_path = storage_root / file_path
         file_path = file_path.resolve()
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1215,7 +1215,7 @@
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
-        if not file_path.exists():
+        if  file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
 
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 410 == 201

E        +  where 410 = <WrapperTestResponse 33 bytes [410 GONE]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1219 File missing on disk for document id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 410 == 201

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1246,7 +1246,7 @@
 
     @app.get("/metrics")
     def metrics():
-        if not _is_authorized_metrics_request():
+        if  _is_authorized_metrics_request():
             # Obscure existence a bit ÔÇô return 404 instead of 403 to casual scans
             app.logger.warning(
                 "Unauthorized metrics access attempt from %s", request.remote_addr
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T205417904435Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T205418783672Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.45s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -34,7 +34,7 @@
 MAX_DB_INT = (2**63) - 1
 
 RMAPHandler = None  # default
-if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
+if not not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
     try:  # Allow tests to disable RMAP dependency via env var
         from rmap_handler import RMAPHandler as _RMAPHandler  # type: ignore
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.39s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -71,7 +71,7 @@
 
     def get_engine():
         eng = app.config.get("_ENGINE")
-        if eng is None:
+        if not eng is None:
             try:
                 eng = create_engine(db_url(), pool_pre_ping=True, future=True)
             except Exception as e:
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: 'NoneType' object has no attribute 'begin'

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: 'NoneType' object has no attribute 'connect'

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T210012324205Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document 'NoneType' object has no attribute 'connect'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T210013064593Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: 'NoneType' object has no attribute 'connect'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: 'NoneType' object has no attribute 'begin'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 19.85s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -81,7 +81,7 @@
         return eng
 
     # --- RMAP initialization (skippable in tests) ---
-    if RMAPHandler is not None:
+    if not RMAPHandler is not None:
         try:
             RMAPHandler(app, str(app.config["STORAGE_DIR"]), get_engine)
         except Exception as e:  # pragma: no cover - defensive; don't fail app
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.80s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -98,7 +98,7 @@
     def require_auth(f):
         @wraps(f)
         def wrapper(*args, **kwargs):
-            if app.config['TESTING']:
+            if not app.config['TESTING']:
                 g.user = {"id": 1, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
...FFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 401 == 201

E            +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 401 == 201

E        +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 401 == 201

E            +  where 401 = <WrapperTestResponse 52 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:95 Auth error (401): Missing or invalid Authorization header

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 401 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 401 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 401 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 401 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 401 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 401 == 200

8 failed, 34 passed, 23 warnings in 20.10s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -102,7 +102,7 @@
                 g.user = {"id": 1, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
-            if not auth.startswith("Bearer "):
+            if not not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
             token = auth.split(" ", 1)[1].strip()
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -136,7 +136,7 @@
     def _tatou_before():
         try:  # record start for latency
             request._tatou_start = time.time()  # type: ignore[attr-defined]
-            route = request.url_rule.rule if request.url_rule else request.path
+            route = request.url_rule.rule if not request.url_rule else request.path
             inc_inflight(route)
             # capture request size if content-length header present
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -141,7 +141,7 @@
             # capture request size if content-length header present
             try:
                 cl = request.content_length
-                if cl is not None:
+                if not cl is not None:
                     observe_request_size(request.method, route, cl)
             except Exception as exc:  # pragma: no cover - soft fail
                 app.logger.warning("Request size capture failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -152,7 +152,7 @@
     def _tatou_after(resp):
         try:
             start = getattr(request, "_tatou_start", None)
-            if start is not None:
+            if not start is not None:
                 dur = time.time() - start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -154,7 +154,7 @@
             start = getattr(request, "_tatou_start", None)
             if start is not None:
                 dur = time.time() - start
-                route = request.url_rule.rule if request.url_rule else request.path
+                route = request.url_rule.rule if not request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
         except Exception as exc:  # pragma: no cover - defensive
             app.logger.warning("after_request instrumentation failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if not len(email) > 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 36 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T211239961138Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T211240774552Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Email or login too long

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.11s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -187,7 +187,7 @@
         """Validate user input before database operations"""
         if len(email) > 320 or len(login) > 64:
             return False, "Email or login too long"
-        if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
+        if not not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid email format

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T165512594775Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T165513529220Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid email format

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.89s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -189,7 +189,7 @@
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
-        if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
+        if not not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
         return True, ""
 
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid login format

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125656930030Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125657761620Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: Invalid login format

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.02s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not not email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194808795106Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194809618728Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 19.78s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -209,7 +209,7 @@
 
         try:
             is_valid, error_msg = validate_user_input(email, login)
-            if not is_valid:
+            if not not is_valid:
                 app.logger.warning("User input validation failed: %s", error_msg)
                 return jsonify({"error": error_msg}), 400
 
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 13 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed:

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T131614667374Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T131615504294Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: 

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.03s

operator: core/AddNot, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -245,7 +245,7 @@
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
-        if not email or not password:
+        if not not email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
             return jsonify({"error": "email and password are required"}), 400
 
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.20s

operator: core/AddNot, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -261,7 +261,7 @@
                 ).first()
 
                 # Constant-time comparison to prevent timing attacks
-                if row:
+                if not row:
                     is_valid = check_password_hash(row.hpassword, password)
                 else:
                     # Dummy check to maintain constant time
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/AddNot, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -268,7 +268,7 @@
                     is_valid = False
                     row = None
 
-                if not is_valid:
+                if not not is_valid:
                     app.logger.warning(
                         "Failed login attempt for email: %s",
                         email if email else "<empty>",
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

1 failed, 41 passed, 23 warnings in 21.16s

operator: core/AddNot, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -271,7 +271,7 @@
                 if not is_valid:
                     app.logger.warning(
                         "Failed login attempt for email: %s",
-                        email if email else "<empty>",
+                        email if not email else "<empty>",
                     )
                     inc_login_failure("invalid_credentials")
                     return jsonify({"error": "invalid credentials"}), 401
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/AddNot, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -298,7 +298,7 @@
     @app.post("/api/upload-document")
     @require_auth
     def upload_document():
-        if "file" not in request.files:
+        if not "file" not in request.files:
             inc_suspicious("upload_missing_file_field")
             app.logger.warning("Upload attempt missing 'file' field")
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 51 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 51 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.21s

operator: core/AddNot, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not not file or file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 27 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:308 Upload attempt with empty filename

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.44s

operator: core/AddNot, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if not file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x0000023F10FED540>('id')

E            +    where <built-in method get of dict object at 0x0000023F10FED540> = {'creation': '2025-10-17T14:51:38.465836', 'id': 3, 'name': 'Water File', 'sha256': '70E80023CAE0AB25227E6F011B7038B7E1F6BDD7AA1D3043E30223BCA945E768', ...}.get



..\test\test_api.py:405: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 40 passed, 23 warnings in 21.62s

operator: core/AddNot, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -317,7 +317,7 @@
             return jsonify({"error": "file too large"}), 413
 
         # Validate file type and MIME type
-        if file.mimetype != "application/pdf":
+        if not file.mimetype != "application/pdf":
             inc_suspicious("upload_bad_mime")
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:322 Upload attempt with invalid MIME type: application/pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.18s

operator: core/AddNot, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -323,7 +323,7 @@
                 "Upload attempt with invalid MIME type: %s", file.mimetype
             )
             return jsonify({"error": "only PDF files are allowed"}), 415
-        if not file.filename.lower().endswith(".pdf"):
+        if not not file.filename.lower().endswith(".pdf"):
             inc_suspicious("upload_bad_extension")
             app.logger.warning(
                 "Upload attempt with invalid file extension: %s", file.filename
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:328 Upload attempt with invalid file extension: input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 415 == 201

E            +  where 415 = <WrapperTestResponse 39 bytes [415 UNSUPPORTED MEDIA TYPE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:328 Upload attempt with invalid file extension: watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 415 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 415 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.25s

operator: core/AddNot, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -332,7 +332,7 @@
 
         # Sanitize filename
         fname = secure_filename(file.filename)
-        if not fname:
+        if not not fname:
             app.logger.warning(
                 "Upload attempt with invalid filename: %s", file.filename
             )
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 29 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:336 Upload attempt with invalid filename: input.pdf

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 29 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:336 Upload attempt with invalid filename: watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.26s

operator: core/AddNot, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -348,7 +348,7 @@
         try:
             # Check for path traversal attempts
             stored_path = (user_dir / stored_name).resolve()
-            if not str(stored_path).startswith(str(user_dir.resolve())):
+            if not not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
                 return jsonify({"error": "invalid path"}), 400
 
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 25 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:352 Upload attempt with invalid path: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T110505652467Z__input.pdf

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 400 == 201

E            +  where 400 = <WrapperTestResponse 25 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:352 Upload attempt with invalid path: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T110506474155Z__watermarked.pdf

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 400 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.48s

operator: core/AddNot, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -403,7 +403,7 @@
             "id": int(row.id),
             "name": row.name,
             "creation": row.creation.isoformat()
-            if hasattr(row.creation, "isoformat")
+            if not hasattr(row.creation, "isoformat")
             else str(row.creation),
             "sha256": row.sha256_hex,
             "size": int(row.size),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/AddNot, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -440,7 +440,7 @@
                 "id": int(r.id),
                 "name": r.name,
                 "creation": r.creation.isoformat()
-                if hasattr(r.creation, "isoformat")
+                if not hasattr(r.creation, "isoformat")
                 else str(r.creation),
                 "sha256": r.sha256_hex,
                 "size": int(r.size),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.70s

operator: core/AddNot, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -455,7 +455,7 @@
     @require_auth
     def list_versions(document_id: int | None = None):
         # Input validation
-        if document_id is None:
+        if not document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195615912518Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195616745321Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.40s

operator: core/AddNot, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -458,7 +458,7 @@
         if document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
-                document_id = int(document_id) if document_id else None
+                document_id = int(document_id) if not document_id else None
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.80s

operator: core/AddNot, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if not document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.91s

operator: core/AddNot, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if not document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.20s

operator: core/AddNot, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -482,7 +482,7 @@
                     {"did": document_id, "uid": int(g.user["id"])},
                 ).first()
 
-                if not doc:
+                if not not doc:
                     app.logger.warning(
                         "Document not found or access denied for id=%s", document_id
                     )
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

1 failed, 41 passed, 23 warnings in 20.92s

operator: core/AddNot, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -526,7 +526,7 @@
     def list_all_versions():
         try:
             # Validate user data from auth token
-            if not g.user or not g.user.get("id"):
+            if not not g.user or not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
                 return jsonify({"error": "Invalid authentication"}), 401
 
......F...................................                               [100%]

================================== FAILURES ===================================

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 35 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:530 Missing user info in auth token

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/AddNot, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -572,7 +572,7 @@
     @require_auth
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
-        if document_id is None:
+        if not document_id is None:
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id)
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 400 == 404

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:460: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 404

2 failed, 40 passed, 23 warnings in 21.24s

operator: core/AddNot, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if not document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T000421930095Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T000423454201Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 24.58s

operator: core/AddNot, occurrence: 35
Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 46, in run_tests
    proc = subprocess.run(shlex.split(command), check=True, env=env, timeout=timeout, capture_output=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pytest', '../test/test_api.py', '../test/test_watermarking_all_methods.py', '../test/test_watermarking_utilities.py']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\mutating.py", line 75, in mutate_and_test
    test_outcome, output = run_tests(test_command, timeout)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 51, in run_tests
    return (TestOutcome.KILLED, err.output.decode("utf-8"))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 5836: invalid start byte
operator: core/AddNot, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -626,7 +626,7 @@
             )
             return jsonify({"error": "document path invalid"}), 500
 
-        if not resolved.exists():
+        if not not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
             return jsonify({"error": "file missing on disk"}), 410
 
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:630 File missing on disk for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 41 passed, 23 warnings in 21.29s

operator: core/AddNot, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -640,7 +640,7 @@
         try:
             # Quick PDF signature check
             head = f.read(5)
-            if head != b"%PDF-":
+            if not head != b"%PDF-":
                 f.close()
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T224817642818Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T224818541971Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.36s

operator: core/AddNot, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -651,7 +651,7 @@
 
             # Prepare safe filename (preserve existing .pdf if present)
             name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
-            if not name.lower().endswith(".pdf"):
+            if not not name.lower().endswith(".pdf"):
                 name = f"{name}.pdf"
 
             # Stat via the same FD to avoid TOCTOU
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/AddNot, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -668,7 +668,7 @@
             )
 
             # Strong validator
-            if isinstance(row.sha256_hex, str) and row.sha256_hex:
+            if not isinstance(row.sha256_hex, str) and row.sha256_hex:
                 resp.set_etag(row.sha256_hex.lower())
 
             # Headers
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/AddNot, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -693,7 +693,7 @@
     @app.get("/api/get-version/<link>")
     def get_version(link: str):
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
-        if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
+        if not not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
             app.logger.warning("Invalid version link format: %s", link)
             return jsonify({"error": "document not found"}), 404
 
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e9a81059278ef320e'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:697 Invalid version link format: 0000000000bc614e9a81059278ef320e

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 20.50s

operator: core/AddNot, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -715,7 +715,7 @@
             inc_db_error("get_version")
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if not not row:
             app.logger.warning("Version not found for link: %s", link)
             return jsonify({"error": "document not found"}), 404
 
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e8239366f32f41753'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:719 Version not found for link: 0000000000bc614e8239366f32f41753

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.38s

operator: core/AddNot, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -727,7 +727,7 @@
             )
             return jsonify({"error": "document path invalid"}), 500
 
-        if not resolved.exists():
+        if not not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
             return jsonify({"error": "file missing on disk"}), 410
 
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614eab52385dc4a4c4d5'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:731 File missing on disk for version link=0000000000bc614eab52385dc4a4c4d5

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.22s

operator: core/AddNot, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -734,7 +734,7 @@
         try:
             with resolved.open("rb") as fh:
                 header = fh.read(5)
-                if header != b"%PDF-":
+                if not header != b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614ee32507434664a7f1'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:738 Invalid PDF signature for version link=0000000000bc614ee32507434664a7f1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 20.98s

operator: core/AddNot, occurrence: 44
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -749,7 +749,7 @@
             return jsonify({"error": "error serving file"}), 500
 
         download_name = (
-            row.link if row.link.lower().endswith(".pdf") else f"{row.link}.pdf"
+            row.link if not row.link.lower().endswith(".pdf") else f"{row.link}.pdf"
         )
         safe_download = download_name.replace("\r", "").replace("\n", "")
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/AddNot, occurrence: 45
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -781,7 +781,7 @@
     def _safe_resolve_under_storage(p: str, storage_root: Path) -> Path:
         storage_root = storage_root.resolve()
         fp = Path(p)
-        if not fp.is_absolute():
+        if not not fp.is_absolute():
             fp = storage_root / fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/AddNot, occurrence: 46
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -785,7 +785,7 @@
             fp = storage_root / fp
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
-        if hasattr(fp, "is_relative_to"):
+        if not hasattr(fp, "is_relative_to"):
             if not fp.is_relative_to(storage_root):
                 raise RuntimeError(f"path {fp} escapes storage root {storage_root}")
         else:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/AddNot, occurrence: 47
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -786,7 +786,7 @@
         fp = fp.resolve()
         # Python 3.12 has is_relative_to on Path
         if hasattr(fp, "is_relative_to"):
-            if not fp.is_relative_to(storage_root):
+            if not not fp.is_relative_to(storage_root):
                 raise RuntimeError(f"path {fp} escapes storage root {storage_root}")
         else:
             try:
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e1e2f0a6102372cfb'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:725 Rejected version path for link 0000000000bc614e1e2f0a6102372cfb: C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\rmap_watermarks\rmap_0000000000bc614e1e2f0a6102372cfb.pdf (path C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\rmap_watermarks\rmap_0000000000bc614e1e2f0a6102372cfb.pdf escapes storage root C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 20.83s

operator: core/AddNot, occurrence: 48
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -803,7 +803,7 @@
     @require_auth
     def delete_document(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
-        if document_id in (None, ""):
+        if not document_id in (None, ""):
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/AddNot, occurrence: 49
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -810,7 +810,7 @@
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
 
-        if document_id is None:
+        if not document_id is None:
             app.logger.warning("Document id required for deletion")
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 20.99s

operator: core/AddNot, occurrence: 50
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if not doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.04s

operator: core/AddNot, occurrence: 51
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -845,7 +845,7 @@
             inc_db_error("delete_document_select")
             return jsonify({"error": "database error during delete"}), 503
 
-        if not row:
+        if not not row:
             # DonÔÇÖt reveal othersÔÇÖ docsÔÇöjust say not found
             app.logger.warning(
                 "Document not found or access denied for deletion id=%s", doc_id
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/AddNot, occurrence: 52
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -859,7 +859,7 @@
         delete_error = None
         try:
             fp = _safe_resolve_under_storage(row.path, storage_root)
-            if fp.exists():
+            if not fp.exists():
                 try:
                     fp.unlink()
                     file_deleted = True
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/AddNot, occurrence: 53
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -908,7 +908,7 @@
     @require_auth
     def create_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
-        if not document_id:
+        if not not document_id:
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.84s

operator: core/AddNot, occurrence: 54
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -930,7 +930,7 @@
 
         # validate input
         try:
-            if doc_id is None:
+            if not doc_id is None:
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T143228907413Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T143229772655Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.33s

operator: core/AddNot, occurrence: 55
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if not doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.69s

operator: core/AddNot, occurrence: 56
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -939,7 +939,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if (
+        if not (
             not method
             or not intended_for
             or not isinstance(secret, str)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T122919412704Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T122920341681Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 21.56s

operator: core/AddNot, occurrence: 57
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -968,7 +968,7 @@
             app.logger.error("Database error fetching document %s", e)
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if not not row:
             app.logger.warning(
                 "Document not found or access denied for watermarking id=%s", doc_id
             )
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

1 failed, 41 passed, 23 warnings in 20.81s

operator: core/AddNot, occurrence: 58
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -977,7 +977,7 @@
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
-        if not file_path.is_absolute():
+        if not not file_path.is_absolute():
             file_path = storage_root / file_path
         file_path = file_path.resolve()
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/AddNot, occurrence: 59
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -985,7 +985,7 @@
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
-        if not file_path.exists():
+        if not not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
 
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 410 == 201

E        +  where 410 = <WrapperTestResponse 33 bytes [410 GONE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:989 File missing on disk for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 410 == 201

1 failed, 41 passed, 23 warnings in 20.78s

operator: core/AddNot, occurrence: 60
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if not applicable is False:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/AddNot, occurrence: 61
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse 44 bytes [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1026 Watermarking produced no output for document 1 using method robust-xmp

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

1 failed, 41 passed, 23 warnings in 20.77s

operator: core/AddNot, occurrence: 62
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1145,7 +1145,7 @@
     @require_auth
     def read_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
-        if not document_id:
+        if not not document_id:
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.08s

operator: core/AddNot, occurrence: 63
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1165,7 +1165,7 @@
 
         # validate input
         try:
-            if doc_id is None:
+            if not doc_id is None:
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.40s

operator: core/AddNot, occurrence: 64
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if not doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.66s

operator: core/AddNot, occurrence: 65
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 41 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'method': 'overlay-watermark', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.52s

operator: core/AddNot, occurrence: 66
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1198,7 +1198,7 @@
             )
             return jsonify({"error": "database error"}), 503
 
-        if not row:
+        if not not row:
             app.logger.warning(
                 "Document not found or access denied for watermark read id=%s", doc_id
             )
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 404 == 201

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/AddNot, occurrence: 67
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1207,7 +1207,7 @@
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
         file_path = Path(row.path)
-        if not file_path.is_absolute():
+        if not not file_path.is_absolute():
             file_path = storage_root / file_path
         file_path = file_path.resolve()
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/AddNot, occurrence: 68
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1215,7 +1215,7 @@
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
-        if not file_path.exists():
+        if not not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
 
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 410 == 201

E        +  where 410 = <WrapperTestResponse 33 bytes [410 GONE]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1219 File missing on disk for document id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 410 == 201

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/AddNot, occurrence: 69
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1240,7 +1240,7 @@
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
-        if provided != token_required:
+        if not provided != token_required:
             return False
         return True
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/AddNot, occurrence: 70
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1246,7 +1246,7 @@
 
     @app.get("/metrics")
     def metrics():
-        if not _is_authorized_metrics_request():
+        if not not _is_authorized_metrics_request():
             # Obscure existence a bit ÔÇô return 404 instead of 403 to casual scans
             app.logger.warning(
                 "Unauthorized metrics access attempt from %s", request.remote_addr
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/AddNot, occurrence: 71
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1261,7 +1261,7 @@
 # WSGI entrypoint
 app = create_app()
 
-if __name__ == "__main__":
+if not __name__ == "__main__":
     port = int(os.environ.get("PORT", 5000))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
timeout
operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -59,7 +59,7 @@
     app.config["DB_PORT"] = int(os.environ.get("DB_PORT", "3306"))
     app.config["DB_NAME"] = os.environ.get("DB_NAME", "tatou")
 
-    app.config["STORAGE_DIR"].mkdir(parents=True, exist_ok=True)
+    app.config["STORAGE_DIR"].mkdir(parents=False, exist_ok=True)
     app.config["TESTING"] = os.environ.get("TESTING", False)
 
     # --- DB engine only (no Table metadata) ---
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceTrueWithFalse, occurrence: 1
Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 46, in run_tests
    proc = subprocess.run(shlex.split(command), check=True, env=env, timeout=timeout, capture_output=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pytest', '../test/test_api.py', '../test/test_watermarking_all_methods.py', '../test/test_watermarking_utilities.py']' returned non-zero exit status 2.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\mutating.py", line 75, in mutate_and_test
    test_outcome, output = run_tests(test_command, timeout)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 51, in run_tests
    return (TestOutcome.KILLED, err.output.decode("utf-8"))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 605: invalid continuation byte
operator: core/ReplaceTrueWithFalse, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -73,7 +73,7 @@
         eng = app.config.get("_ENGINE")
         if eng is None:
             try:
-                eng = create_engine(db_url(), pool_pre_ping=True, future=True)
+                eng = create_engine(db_url(), pool_pre_ping=False, future=True)
             except Exception as e:
                 app.logger.critical("Failed to initialize database engine: %s", e)
                 raise
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceTrueWithFalse, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -73,7 +73,7 @@
         eng = app.config.get("_ENGINE")
         if eng is None:
             try:
-                eng = create_engine(db_url(), pool_pre_ping=True, future=True)
+                eng = create_engine(db_url(), pool_pre_ping=True, future=False)
             except Exception as e:
                 app.logger.critical("Failed to initialize database engine: %s", e)
                 raise
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:236 Database error in create_user: The 'future' parameter passed to create_engine() may only be set to True.

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:280 Database error in login: The 'future' parameter passed to create_engine() may only be set to True.

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T113141022542Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:968 Database error fetching document The 'future' parameter passed to create_engine() may only be set to True.

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T113141759089Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:844 DB delete error for doc id=2: The 'future' parameter passed to create_engine() may only be set to True.

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

ERROR    server:server.py:236 Database error in create_user: The 'future' parameter passed to create_engine() may only be set to True.

CRITICAL server:server.py:78 Failed to initialize database engine: The 'future' parameter passed to create_engine() may only be set to True.

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 19.80s

operator: core/ReplaceTrueWithFalse, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -175,7 +175,7 @@
         try:
             with get_engine().connect() as conn:
                 conn.execute(text("SELECT 1"))
-            db_ok = True
+            db_ok = False
         except Exception:
             db_ok = False
         return jsonify(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceTrueWithFalse, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -191,7 +191,7 @@
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
-        return True, ""
+        return False, ""
 
     # POST /api/create-user {email, login, password}
     @app.post("/api/create-user")
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 13 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed:

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T192136793682Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T192137708058Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:213 User input validation failed: 

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.30s

operator: core/ReplaceTrueWithFalse, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -196,7 +196,7 @@
     # POST /api/create-user {email, login, password}
     @app.post("/api/create-user")
     def create_user():
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=False) or {}
         email = (payload.get("email") or "").strip().lower()
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceTrueWithFalse, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -241,7 +241,7 @@
     # POST /api/login {login, password}
     @app.post("/api/login")
     def login():
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=False) or {}
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceTrueWithFalse, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -339,7 +339,7 @@
             return jsonify({"error": "invalid filename"}), 400
 
         user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
-        user_dir.mkdir(parents=True, exist_ok=True)
+        user_dir.mkdir(parents=False, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
         final_name = request.form.get("name") or fname
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceTrueWithFalse, occurrence: 9
Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 46, in run_tests
    proc = subprocess.run(shlex.split(command), check=True, env=env, timeout=timeout, capture_output=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pytest', '../test/test_api.py', '../test/test_watermarking_all_methods.py', '../test/test_watermarking_utilities.py']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\mutating.py", line 75, in mutate_and_test
    test_outcome, output = run_tests(test_command, timeout)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 51, in run_tests
    return (TestOutcome.KILLED, err.output.decode("utf-8"))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 6287: invalid continuation byte
operator: core/ReplaceTrueWithFalse, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -389,7 +389,7 @@
                     {"id": did},
                 ).one()
         except Exception:
-            stored_path.unlink(missing_ok=True)
+            stored_path.unlink(missing_ok=False)
             app.logger.error(
                 "Database error inserting document path=%s user=%s",
                 stored_path,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceTrueWithFalse, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -759,7 +759,7 @@
                 mimetype="application/pdf",
                 as_attachment=False,
                 download_name=safe_download,
-                conditional=True,
+                conditional=False,
                 max_age=0,
                 last_modified=last_modified,
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceTrueWithFalse, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -807,7 +807,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=False) or {}).get("id"))
             )
 
         if document_id is None:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceTrueWithFalse, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -862,7 +862,7 @@
             if fp.exists():
                 try:
                     fp.unlink()
-                    file_deleted = True
+                    file_deleted = False
                 except Exception as e:
                     delete_error = f"failed to delete file: {e}"
                     app.logger.warning(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceTrueWithFalse, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -869,7 +869,7 @@
                         "Failed to delete file %s for doc id=%s: %s", fp, row.id, e
                     )
             else:
-                file_missing = True
+                file_missing = False
         except RuntimeError as e:
             # Path escapes storage root; refuse to touch the file
             delete_error = str(e)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.25s

operator: core/ReplaceTrueWithFalse, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -893,7 +893,7 @@
 
         return jsonify(
             {
-                "deleted": True,
+                "deleted": False,
                 "id": doc_id,
                 "file_deleted": file_deleted,
                 "file_missing": file_missing,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceTrueWithFalse, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -912,7 +912,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=False) or {}).get("id"))
             )
         try:
             doc_id = document_id
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T190857322224Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T190858191786Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.66s

operator: core/ReplaceTrueWithFalse, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -920,7 +920,7 @@
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=False) or {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
         intended_for = payload.get("intended_for")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceTrueWithFalse, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1043,7 +1043,7 @@
         base_name = Path(row.name or file_path.name).stem
         intended_slug = secure_filename(intended_for)
         dest_dir = file_path.parent / "watermarks"
-        dest_dir.mkdir(parents=True, exist_ok=True)
+        dest_dir.mkdir(parents=False, exist_ok=True)
 
         candidate = f"{base_name}__{intended_slug}.pdf"
         dest_path = dest_dir / candidate
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ReplaceTrueWithFalse, occurrence: 19
Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 46, in run_tests
    proc = subprocess.run(shlex.split(command), check=True, env=env, timeout=timeout, capture_output=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pytest', '../test/test_api.py', '../test/test_watermarking_all_methods.py', '../test/test_watermarking_utilities.py']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\mutating.py", line 75, in mutate_and_test
    test_outcome, output = run_tests(test_command, timeout)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cosmic_ray\testing.py", line 51, in run_tests
    return (TestOutcome.KILLED, err.output.decode("utf-8"))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 3971: invalid continuation byte
operator: core/ReplaceTrueWithFalse, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1089,7 +1089,7 @@
         except IntegrityError as ie:
             # This should be very rare due to SHA-256 usage, but handle it just in case
             try:
-                dest_path.unlink(missing_ok=True)
+                dest_path.unlink(missing_ok=False)
             except Exception as cleanup_error:
                 app.logger.warning(
                     f"Failed to cleanup file {dest_path}: {cleanup_error}"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceTrueWithFalse, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1101,7 +1101,7 @@
             return jsonify({"error": "database error during version insert"}), 503
         except Exception:
             try:
-                dest_path.unlink(missing_ok=True)
+                dest_path.unlink(missing_ok=False)
             except Exception as cleanup_error:
                 app.logger.warning(
                     f"Failed to cleanup file {dest_path}: {cleanup_error}"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceTrueWithFalse, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1149,7 +1149,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=False) or {}).get("id"))
             )
         try:
             doc_id = document_id
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ReplaceTrueWithFalse, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1157,7 +1157,7 @@
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=False) or {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
         position = payload.get("position") or None
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceTrueWithFalse, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1242,7 +1242,7 @@
         provided = request.headers.get("X-Metrics-Token", "")
         if provided != token_required:
             return False
-        return True
+        return False
 
     @app.get("/metrics")
     def metrics():
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -60,7 +60,7 @@
     app.config["DB_NAME"] = os.environ.get("DB_NAME", "tatou")
 
     app.config["STORAGE_DIR"].mkdir(parents=True, exist_ok=True)
-    app.config["TESTING"] = os.environ.get("TESTING", False)
+    app.config["TESTING"] = os.environ.get("TESTING", True)
 
     # --- DB engine only (no Table metadata) ---
     def db_url() -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -177,7 +177,7 @@
                 conn.execute(text("SELECT 1"))
             db_ok = True
         except Exception:
-            db_ok = False
+            db_ok = True
         return jsonify(
             {"message": "The server is up and running.", "db_connected": db_ok}
         ), 200
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceFalseWithTrue, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -186,7 +186,7 @@
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
         if len(email) > 320 or len(login) > 64:
-            return False, "Email or login too long"
+            return True, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceFalseWithTrue, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -188,7 +188,7 @@
         if len(email) > 320 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
-            return False, "Invalid email format"
+            return True, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
         return True, ""
.FF.......................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 201  # Endpoint should exist

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("id"), int)

        assert isinstance(resp_data.get("login"), str)

        assert isinstance(resp_data.get("email"), str)

        #check values are what we submitted

        assert resp_data.get("login") == parameters["login"]

        assert resp_data.get("email") == parameters["email"]

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/create-user",json={

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

        assert resp.status_code == 400

    

        # Missing login

        resp = client.post("/api/create-user",

                json={"email": "user@email.se", "password": "password"},

        )

        assert resp.status_code == 400

    

        # Missing password

        resp = client.post(

        "/api/create-user", json={"email": "user@email.se", "login": "username"}

        )

        assert resp.status_code == 400

    

        # Malformed email

        resp = client.post("/api/create-user",json={

                    "email": "malformedemail",

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

>       assert resp.status_code == 400

E       assert 201 == 400

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:114: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'login': 'username', 'password': 'password'}

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'password': 'password'}

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("token"), str)

        assert isinstance(resp_data.get("token_type"), str)

        assert isinstance(resp_data.get("expires_in"), int)

        #check val

        assert resp_data.get("token_type") == "bearer"

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/login", json={"password": "password"})

        assert resp.status_code == 400

        # Missing password

        resp = client.post("/api/login", json={"email": "user@email.se"})

        assert resp.status_code == 400

        # Both missing

        resp = client.post("/api/login", json={})

        assert resp.status_code == 400

        # Malformed email - counts as non existing

        resp = client.post("/api/login", json={"email": "malformedemail", "password": "password"})

>       assert resp.status_code == 401

E       assert 200 == 401

E        +  where 200 = <WrapperTestResponse streamed [200 OK]>.status_code



..\test\test_api.py:150: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'password': 'password'}

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se'}

WARNING  server:server.py:249 Missing fields in login attempt: {}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 201 == 400

FAILED ..\test\test_api.py::test_login_route - assert 200 == 401

2 failed, 40 passed, 23 warnings in 21.45s

operator: core/ReplaceFalseWithTrue, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -190,7 +190,7 @@
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
-            return False, "Invalid login format"
+            return True, "Invalid login format"
         return True, ""
 
     # POST /api/create-user {email, login, password}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceFalseWithTrue, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -265,7 +265,7 @@
                     is_valid = check_password_hash(row.hpassword, password)
                 else:
                     # Dummy check to maintain constant time
-                    is_valid = False
+                    is_valid = True
                     row = None
 
                 if not is_valid:
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("token"), str)

        assert isinstance(resp_data.get("token_type"), str)

        assert isinstance(resp_data.get("expires_in"), int)

        #check val

        assert resp_data.get("token_type") == "bearer"

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/login", json={"password": "password"})

        assert resp.status_code == 400

        # Missing password

        resp = client.post("/api/login", json={"email": "user@email.se"})

        assert resp.status_code == 400

        # Both missing

        resp = client.post("/api/login", json={})

        assert resp.status_code == 400

        # Malformed email - counts as non existing

>       resp = client.post("/api/login", json={"email": "malformedemail", "password": "password"})

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:149: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.post("/api/login")

    def login():

        payload = request.get_json(silent=True) or {}

        email = (payload.get("email") or "").strip()

        password = payload.get("password") or ""

    

        if not email or not password:

            app.logger.warning("Missing fields in login attempt: %s", payload)

            return jsonify({"error": "email and password are required"}), 400

    

        start_db = time.time()

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        "SELECT id, email, login, hpassword FROM Users "

                        "WHERE email = :email LIMIT 1"

                    ),

                    {"email": email},

                ).first()

    

                # Constant-time comparison to prevent timing attacks

                if row:

                    is_valid = check_password_hash(row.hpassword, password)

                else:

                    # Dummy check to maintain constant time

                    is_valid = True

                    row = None

    

                if not is_valid:

                    app.logger.warning(

                        "Failed login attempt for email: %s",

                        email if email else "<empty>",

                    )

                    inc_login_failure("invalid_credentials")

                    return jsonify({"error": "invalid credentials"}), 401

    

        except Exception as e:

            app.logger.error("Database error in login: %s", e)

            inc_db_error("login_select")

            return jsonify({"error": "An error occurred"}), 503

    

        observe_db_latency("login_select", time.time() - start_db)

        token = _serializer().dumps(

>           {"uid": int(row.id), "login": row.login, "email": row.email}

                        ^^^^^^

        )

E       AttributeError: 'NoneType' object has no attribute 'id'



server.py:286: AttributeError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'password': 'password'}

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se'}

WARNING  server:server.py:249 Missing fields in login attempt: {}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - AttributeError: 'NoneType' obj...

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/ReplaceFalseWithTrue, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -660,7 +660,7 @@
             resp = send_file(
                 file_path,
                 mimetype="application/pdf",
-                as_attachment=False,
+                as_attachment=True,
                 download_name=name,
                 conditional=False,  # enables 304 if If-Modified-Since/Range handling
                 max_age=0,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.21s

operator: core/ReplaceFalseWithTrue, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -662,7 +662,7 @@
                 mimetype="application/pdf",
                 as_attachment=False,
                 download_name=name,
-                conditional=False,  # enables 304 if If-Modified-Since/Range handling
+                conditional=True,  # enables 304 if If-Modified-Since/Range handling
                 max_age=0,
                 last_modified=st.st_mtime,
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceFalseWithTrue, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -757,7 +757,7 @@
             resp = send_file(
                 resolved,
                 mimetype="application/pdf",
-                as_attachment=False,
+                as_attachment=True,
                 download_name=safe_download,
                 conditional=True,
                 max_age=0,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.62s

operator: core/ReplaceFalseWithTrue, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -854,7 +854,7 @@
 
         # Resolve and delete file (best effort)
         storage_root = Path(app.config["STORAGE_DIR"])
-        file_deleted = False
+        file_deleted = True
         file_missing = False
         delete_error = None
         try:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T111402115351Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T111402975838Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.67s

operator: core/ReplaceFalseWithTrue, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -855,7 +855,7 @@
         # Resolve and delete file (best effort)
         storage_root = Path(app.config["STORAGE_DIR"])
         file_deleted = False
-        file_missing = False
+        file_missing = True
         delete_error = None
         try:
             fp = _safe_resolve_under_storage(row.path, storage_root)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceFalseWithTrue, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -994,7 +994,7 @@
             applicable = WMUtils.is_watermarking_applicable(
                 method=method, pdf=str(file_path), position=position
             )
-            if applicable is False:
+            if applicable is True:
                 inc_watermark_failed(method, "applicability")
                 app.logger.info(
                     "Watermarking method %s not applicable for document %s",
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 47 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.70s

operator: core/ReplaceFalseWithTrue, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1241,7 +1241,7 @@
         token_required = os.environ.get("METRICS_TOKEN", "")
         provided = request.headers.get("X-Metrics-Token", "")
         if provided != token_required:
-            return False
+            return True
         return True
 
     @app.get("/metrics")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceAndWithOr, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -311,7 +311,7 @@
         start_db = time.time()
         # Validate file size
         MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
-        if file.content_length and file.content_length > MAX_FILE_SIZE:
+        if file.content_length or file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
             return jsonify({"error": "file too large"}), 413
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceAndWithOr, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -668,7 +668,7 @@
             )
 
             # Strong validator
-            if isinstance(row.sha256_hex, str) and row.sha256_hex:
+            if isinstance(row.sha256_hex, str) or row.sha256_hex:
                 resp.set_etag(row.sha256_hex.lower())
 
             # Headers
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.35s

operator: core/ReplaceAndWithOr, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -807,7 +807,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json or (request.get_json(silent=True) or {}).get("id"))
             )
 
         if document_id is None:
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 200 == 404

E        +  where 200 = <WrapperTestResponse streamed [200 OK]>.status_code



..\test\test_api.py:460: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 200 == 404

1 failed, 41 passed, 23 warnings in 21.19s

operator: core/ReplaceAndWithOr, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -912,7 +912,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json or (request.get_json(silent=True) or {}).get("id"))
             )
         try:
             doc_id = document_id
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

>       assert resp.status_code == 404

E       assert 503 == 404

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:365: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 404

1 failed, 41 passed, 23 warnings in 21.39s

operator: core/ReplaceAndWithOr, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1149,7 +1149,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json or (request.get_json(silent=True) or {}).get("id"))
             )
         try:
             doc_id = document_id
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

>       assert data.get("documentid") == parameters["id"]

E       AssertionError: assert 1 == 2

E        +  where 1 = <built-in method get of dict object at 0x0000020085A94DC0>('documentid')

E        +    where <built-in method get of dict object at 0x0000020085A94DC0> = {'documentid': 1, 'method': 'overlay-watermark', 'position': 'metadata-only', 'secret': 'None'}.get



..\test\test_api.py:423: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

1 failed, 41 passed, 23 warnings in 21.08s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 and len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T231807011048Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T231807893140Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.38s

operator: core/ReplaceOrWithAnd, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -196,7 +196,7 @@
     # POST /api/create-user {email, login, password}
     @app.post("/api/create-user")
     def create_user():
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=True) and {}
         email = (payload.get("email") or "").strip().lower()
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150609595359Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150610436749Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 19.91s

operator: core/ReplaceOrWithAnd, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -197,7 +197,7 @@
     @app.post("/api/create-user")
     def create_user():
         payload = request.get_json(silent=True) or {}
-        email = (payload.get("email") or "").strip().lower()
+        email = (payload.get("email") and "").strip().lower()
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144904658323Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144905530265Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.22s

operator: core/ReplaceOrWithAnd, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -198,7 +198,7 @@
     def create_user():
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip().lower()
-        login = (payload.get("login") or "").strip()
+        login = (payload.get("login") and "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
         if not email or not login or not password:
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T233626443134Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T233627299532Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.03s

operator: core/ReplaceOrWithAnd, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -199,7 +199,7 @@
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip().lower()
         login = (payload.get("login") or "").strip()
-        password = payload.get("password") or ""
+        password = payload.get("password") and ""
         start_db = time.time()
         if not email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username', 'password': 'password'}

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T000158057666Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T000158886796Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'service@rmap.su', 'login': 'rmap_service', 'password': 'password_rmap'}

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 400 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.54s

operator: core/ReplaceOrWithAnd, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not email and not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.26s

operator: core/ReplaceOrWithAnd, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -201,7 +201,7 @@
         login = (payload.get("login") or "").strip()
         password = payload.get("password") or ""
         start_db = time.time()
-        if not email or not login or not password:
+        if not email or not login and not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
             return jsonify({"error": "email, login, and password are required"}), 400
 
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 201  # Endpoint should exist

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("id"), int)

        assert isinstance(resp_data.get("login"), str)

        assert isinstance(resp_data.get("email"), str)

        #check values are what we submitted

        assert resp_data.get("login") == parameters["login"]

        assert resp_data.get("email") == parameters["email"]

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/create-user",json={

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

        assert resp.status_code == 400

    

        # Missing login

        resp = client.post("/api/create-user",

                json={"email": "user@email.se", "password": "password"},

        )

        assert resp.status_code == 400

    

        # Missing password

        resp = client.post(

        "/api/create-user", json={"email": "user@email.se", "login": "username"}

        )

>       assert resp.status_code == 400

E       assert 409 == 400

E        +  where 409 = <WrapperTestResponse streamed [409 CONFLICT]>.status_code



..\test\test_api.py:105: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'login': 'username', 'password': 'password'}

WARNING  server:server.py:213 User input validation failed: Invalid login format

WARNING  server:server.py:231 Attempt to create duplicate user: email=user@email.se, login=username

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 409 == 400

1 failed, 41 passed, 23 warnings in 21.17s

operator: core/ReplaceOrWithAnd, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -241,7 +241,7 @@
     # POST /api/login {login, password}
     @app.post("/api/login")
     def login():
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=True) and {}
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.05s

operator: core/ReplaceOrWithAnd, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -242,7 +242,7 @@
     @app.post("/api/login")
     def login():
         payload = request.get_json(silent=True) or {}
-        email = (payload.get("email") or "").strip()
+        email = (payload.get("email") and "").strip()
         password = payload.get("password") or ""
 
         if not email or not password:
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.08s

operator: core/ReplaceOrWithAnd, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -243,7 +243,7 @@
     def login():
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip()
-        password = payload.get("password") or ""
+        password = payload.get("password") and ""
 
         if not email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 44 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se', 'password': 'password'}

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T214057826394Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T214058666824Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 400 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.45s

operator: core/ReplaceOrWithAnd, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -245,7 +245,7 @@
         email = (payload.get("email") or "").strip()
         password = payload.get("password") or ""
 
-        if not email or not password:
+        if not email and not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
             return jsonify({"error": "email and password are required"}), 400
 
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("token"), str)

        assert isinstance(resp_data.get("token_type"), str)

        assert isinstance(resp_data.get("expires_in"), int)

        #check val

        assert resp_data.get("token_type") == "bearer"

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/login", json={"password": "password"})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:141: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: <empty>

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/ReplaceOrWithAnd, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -304,7 +304,7 @@
             return jsonify({"error": "file is required (multipart/form-data)"}), 400
 
         file = request.files["file"]
-        if not file or file.filename == "":
+        if not file and file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
             return jsonify({"error": "empty filename"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceOrWithAnd, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -342,7 +342,7 @@
         user_dir.mkdir(parents=True, exist_ok=True)
 
         ts = dt.datetime.now(dt.UTC).strftime("%Y%m%dT%H%M%S%fZ")
-        final_name = request.form.get("name") or fname
+        final_name = request.form.get("name") and fname
         stored_name = f"{ts}__{fname}"
 
         try:
...F......................................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

>           assert resp_data.get("name") == parameters["name"]

E           AssertionError: assert 'input.pdf' == 'My File'

E             

E             - My File

E             + input.pdf



..\test\test_api.py:176: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - AssertionError: asse...

1 failed, 41 passed, 23 warnings in 20.76s

operator: core/ReplaceOrWithAnd, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -456,7 +456,7 @@
     def list_versions(document_id: int | None = None):
         # Input validation
         if document_id is None:
-            document_id = request.args.get("id") or request.args.get("documentid")
+            document_id = request.args.get("id") and request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.03s

operator: core/ReplaceOrWithAnd, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None and document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceOrWithAnd, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 0 and document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.60s

operator: core/ReplaceOrWithAnd, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None and document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T155358535914Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T155359430167Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.70s

operator: core/ReplaceOrWithAnd, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 and document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T135635378142Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T135636211957Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.40s

operator: core/ReplaceOrWithAnd, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -526,7 +526,7 @@
     def list_all_versions():
         try:
             # Validate user data from auth token
-            if not g.user or not g.user.get("id"):
+            if not g.user and not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
                 return jsonify({"error": "Invalid authentication"}), 401
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T213216200890Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T213217052643Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.33s

operator: core/ReplaceOrWithAnd, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -573,7 +573,7 @@
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
-            document_id = request.args.get("id") or request.args.get("documentid")
+            document_id = request.args.get("id") and request.args.get("documentid")
             try:
                 document_id = int(document_id)
             except (TypeError, ValueError):
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/ReplaceOrWithAnd, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None and document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceOrWithAnd, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 0 and document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceOrWithAnd, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -650,7 +650,7 @@
             f.seek(0)
 
             # Prepare safe filename (preserve existing .pdf if present)
-            name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
+            name = (row.name and "document").strip().replace("\r", "").replace("\n", "")
             if not name.lower().endswith(".pdf"):
                 name = f"{name}.pdf"
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/ReplaceOrWithAnd, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -806,7 +806,7 @@
         if document_id in (None, ""):
             document_id = (
                 request.args.get("id")
-                or request.args.get("documentid")
+                and request.args.get("documentid")
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceOrWithAnd, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -807,7 +807,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                and (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
 
         if document_id is None:
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.22s

operator: core/ReplaceOrWithAnd, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -807,7 +807,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=True) and {}).get("id"))
             )
 
         if document_id is None:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T001040485116Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T001041339371Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:814 Document id required for deletion

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

10 failed, 32 passed, 23 warnings in 20.77s

operator: core/ReplaceOrWithAnd, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 0 and doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T222401504212Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T222402401969Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.27s

operator: core/ReplaceOrWithAnd, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -911,7 +911,7 @@
         if not document_id:
             document_id = (
                 request.args.get("id")
-                or request.args.get("documentid")
+                and request.args.get("documentid")
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/ReplaceOrWithAnd, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -912,7 +912,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                and (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
         try:
             doc_id = document_id
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.93s

operator: core/ReplaceOrWithAnd, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -912,7 +912,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=True) and {}).get("id"))
             )
         try:
             doc_id = document_id
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.03s

operator: core/ReplaceOrWithAnd, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -920,7 +920,7 @@
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=True) and {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
         intended_for = payload.get("intended_for")
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 63 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:948 Missing required fields for watermarking: {}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.86s

operator: core/ReplaceOrWithAnd, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -924,7 +924,7 @@
         # allow a couple of aliases for convenience
         method = payload.get("method")
         intended_for = payload.get("intended_for")
-        position = payload.get("position") or None
+        position = payload.get("position") and None
         secret = payload.get("secret")
         key = payload.get("key")
 
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

>       assert isinstance(data.get("position"), str)

E       AssertionError: assert False

E        +  where False = isinstance(None, str)

E        +    where None = <built-in method get of dict object at 0x00000245810F0640>('position')

E        +      where <built-in method get of dict object at 0x00000245810F0640> = {'documentid': 1, 'filename': 'My File__Mickey_Mouse.pdf', 'id': 1, 'intended_for': 'Mickey Mouse', ...}.get



..\test\test_api.py:345: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - AssertionError: ass...

1 failed, 41 passed, 23 warnings in 20.93s

operator: core/ReplaceOrWithAnd, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 and doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.59s

operator: core/ReplaceOrWithAnd, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -941,7 +941,7 @@
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
             not method
-            or not intended_for
+            and not intended_for
             or not isinstance(secret, str)
             or not isinstance(key, str)
         ):
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

        assert resp.status_code == 201

        #Missing key

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing secret

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                         "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing recipient

>       resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret",  "id": 1})



..\test\test_api.py:388: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

server.py:1044: in create_watermark

    intended_slug = secure_filename(intended_for)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



filename = None



    def secure_filename(filename: str) -> str:

        r"""Pass it a filename and it will return a secure version of it.  This

        filename can then safely be stored on a regular file system and passed

        to :func:`os.path.join`.  The filename returned is an ASCII only string

        for maximum portability.

    

        On windows systems the function also makes sure that the file is not

        named after one of the special device files.

    

        >>> secure_filename("My cool movie.mov")

        'My_cool_movie.mov'

        >>> secure_filename("../../../etc/passwd")

        'etc_passwd'

        >>> secure_filename('i contain cool \xfcml\xe4uts.txt')

        'i_contain_cool_umlauts.txt'

    

        The function might return an empty filename.  It's your responsibility

        to ensure that the filename is unique and that you abort or

        generate a random filename if the function returned an empty one.

    

        .. versionadded:: 0.5

    

        :param filename: the filename to secure

        """

>       filename = unicodedata.normalize("NFKD", filename)

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: normalize() argument 2 must be str, not None



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\utils.py:219: TypeError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: None. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'method': 'robust-xmp', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - TypeError: normaliz...

1 failed, 41 passed, 23 warnings in 21.16s

operator: core/ReplaceOrWithAnd, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -942,7 +942,7 @@
         if (
             not method
             or not intended_for
-            or not isinstance(secret, str)
+            and not isinstance(secret, str)
             or not isinstance(key, str)
         ):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

        assert resp.status_code == 201

        #Missing key

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing secret

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                         "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 500 == 400

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:386: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'method': 'robust-xmp', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: 'NoneType' object has no attribute 'strip'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 400

1 failed, 41 passed, 23 warnings in 21.02s

operator: core/ReplaceOrWithAnd, occurrence: 35
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -943,7 +943,7 @@
             not method
             or not intended_for
             or not isinstance(secret, str)
-            or not isinstance(key, str)
+            and not isinstance(key, str)
         ):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify(
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

        assert resp.status_code == 201

        #Missing key

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 500 == 400

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:382: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method robust-xmp: 'NoneType' object has no attribute 'strip'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 400

1 failed, 41 passed, 23 warnings in 21.99s

operator: core/ReplaceOrWithAnd, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) and len(wm_bytes) == 0:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceOrWithAnd, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1040,7 +1040,7 @@
             return jsonify({"error": "watermarking failed"}), 500
 
         # build destination file name: "<original_name>__<intended_to>.pdf"
-        base_name = Path(row.name or file_path.name).stem
+        base_name = Path(row.name and file_path.name).stem
         intended_slug = secure_filename(intended_for)
         dest_dir = file_path.parent / "watermarks"
         dest_dir.mkdir(parents=True, exist_ok=True)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceOrWithAnd, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1081,7 +1081,7 @@
                         "intended_for": intended_for,
                         "secret": secret,
                         "method": method,
-                        "position": position or "",
+                        "position": position and "",
                         "path": str(dest_path),
                     },
                 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceOrWithAnd, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1148,7 +1148,7 @@
         if not document_id:
             document_id = (
                 request.args.get("id")
-                or request.args.get("documentid")
+                and request.args.get("documentid")
                 or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceOrWithAnd, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1149,7 +1149,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                and (request.is_json and (request.get_json(silent=True) or {}).get("id"))
             )
         try:
             doc_id = document_id
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.04s

operator: core/ReplaceOrWithAnd, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1149,7 +1149,7 @@
             document_id = (
                 request.args.get("id")
                 or request.args.get("documentid")
-                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))
+                or (request.is_json and (request.get_json(silent=True) and {}).get("id"))
             )
         try:
             doc_id = document_id
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.96s

operator: core/ReplaceOrWithAnd, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1157,7 +1157,7 @@
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        payload = request.get_json(silent=True) or {}
+        payload = request.get_json(silent=True) and {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
         position = payload.get("position") or None
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 41 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1178 Missing required fields for watermarking: {}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/ReplaceOrWithAnd, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1160,7 +1160,7 @@
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
         method = payload.get("method")
-        position = payload.get("position") or None
+        position = payload.get("position") and None
         key = payload.get("key")
 
         # validate input
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

>       assert isinstance(data.get("position"), str)

E       AssertionError: assert False

E        +  where False = isinstance(None, str)

E        +    where None = <built-in method get of dict object at 0x0000014E112A4740>('position')

E        +      where <built-in method get of dict object at 0x0000014E112A4740> = {'documentid': 2, 'method': 'overlay-watermark', 'position': None, 'secret': 'None'}.get



..\test\test_api.py:421: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

1 failed, 41 passed, 23 warnings in 21.12s

operator: core/ReplaceOrWithAnd, occurrence: 44
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 0 and doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.25s

operator: core/ReplaceOrWithAnd, occurrence: 45
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not method and not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T135901927630Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T135902867666Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.67s

operator: core/ReplaceOrWithAnd, occurrence: 46
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1174,7 +1174,7 @@
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
-        if not method or not isinstance(method, str) or not isinstance(key, str):
+        if not method or not isinstance(method, str) and not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T101501792275Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T101502668513Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.50s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -39,7 +39,7 @@
         from rmap_handler import RMAPHandler as _RMAPHandler  # type: ignore
 
         RMAPHandler = _RMAPHandler
-    except Exception:  # pragma: no cover - degrade gracefully if missing
+    except CosmicRayTestingException:  # pragma: no cover - degrade gracefully if missing
         RMAPHandler = None  # type: ignore
 
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -74,7 +74,7 @@
         if eng is None:
             try:
                 eng = create_engine(db_url(), pool_pre_ping=True, future=True)
-            except Exception as e:
+            except CosmicRayTestingException as e:
                 app.logger.critical("Failed to initialize database engine: %s", e)
                 raise
             app.config["_ENGINE"] = eng
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -84,7 +84,7 @@
     if RMAPHandler is not None:
         try:
             RMAPHandler(app, str(app.config["STORAGE_DIR"]), get_engine)
-        except Exception as e:  # pragma: no cover - defensive; don't fail app
+        except CosmicRayTestingException as e:  # pragma: no cover - defensive; don't fail app
             app.logger.warning("RMAP initialization failed (continuing): %s", e)
 
     # --- Helpers ---
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T132425721613Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T132426624626Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.73s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -109,7 +109,7 @@
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
                 )
-            except SignatureExpired:
+            except CosmicRayTestingException:
                 return _auth_error("Token expired")
             except BadSignature:
                 return _auth_error("Invalid token")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -111,7 +111,7 @@
                 )
             except SignatureExpired:
                 return _auth_error("Token expired")
-            except BadSignature:
+            except CosmicRayTestingException:
                 return _auth_error("Invalid token")
             g.user = {
                 "id": int(data["uid"]),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.61s

operator: core/ExceptionReplacer, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -143,7 +143,7 @@
                 cl = request.content_length
                 if cl is not None:
                     observe_request_size(request.method, route, cl)
-            except Exception as exc:  # pragma: no cover - soft fail
+            except CosmicRayTestingException as exc:  # pragma: no cover - soft fail
                 app.logger.warning("Request size capture failed: %s", exc)
         except Exception as exc:  # pragma: no cover - defensive
             app.logger.warning("before_request instrumentation failed: %s", exc)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T233354722759Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T233355593045Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.49s

operator: core/ExceptionReplacer, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -145,7 +145,7 @@
                     observe_request_size(request.method, route, cl)
             except Exception as exc:  # pragma: no cover - soft fail
                 app.logger.warning("Request size capture failed: %s", exc)
-        except Exception as exc:  # pragma: no cover - defensive
+        except CosmicRayTestingException as exc:  # pragma: no cover - defensive
             app.logger.warning("before_request instrumentation failed: %s", exc)
 
     @app.after_request  # type: ignore
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.87s

operator: core/ExceptionReplacer, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -156,7 +156,7 @@
                 dur = time.time() - start
                 route = request.url_rule.rule if request.url_rule else request.path
                 record_request(request.method, route, resp.status_code, dur)
-        except Exception as exc:  # pragma: no cover - defensive
+        except CosmicRayTestingException as exc:  # pragma: no cover - defensive
             app.logger.warning("after_request instrumentation failed: %s", exc)
         return resp
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193833481004Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193834385972Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.47s

operator: core/ExceptionReplacer, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -176,7 +176,7 @@
             with get_engine().connect() as conn:
                 conn.execute(text("SELECT 1"))
             db_ok = True
-        except Exception:
+        except CosmicRayTestingException:
             db_ok = False
         return jsonify(
             {"message": "The server is up and running.", "db_connected": db_ok}
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ExceptionReplacer, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -227,7 +227,7 @@
                     {"id": uid},
                 ).one()
             observe_db_latency("create_user", time.time() - start_db)
-        except IntegrityError:
+        except CosmicRayTestingException:
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ExceptionReplacer, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -232,7 +232,7 @@
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
             )
             return jsonify({"error": "email or login already exists"}), 409
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ExceptionReplacer, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -276,7 +276,7 @@
                     inc_login_failure("invalid_credentials")
                     return jsonify({"error": "invalid credentials"}), 401
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Database error in login: %s", e)
             inc_db_error("login_select")
             return jsonify({"error": "An error occurred"}), 503
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ExceptionReplacer, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -353,7 +353,7 @@
                 return jsonify({"error": "invalid path"}), 400
 
             file.save(stored_path)
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("File save error: %s", e)
             return jsonify({"error": "failed to save file"}), 500
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ExceptionReplacer, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -388,7 +388,7 @@
                     ),
                     {"id": did},
                 ).one()
-        except Exception:
+        except CosmicRayTestingException:
             stored_path.unlink(missing_ok=True)
             app.logger.error(
                 "Database error inserting document path=%s user=%s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ExceptionReplacer, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -428,7 +428,7 @@
                     ),
                     {"uid": int(g.user["id"])},
                 ).all()
-        except Exception:
+        except CosmicRayTestingException:
             app.logger.error(
                 "Database error in list_documents for user=%s", g.user["id"]
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ExceptionReplacer, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -462,7 +462,7 @@
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
-            except (TypeError, ValueError):
+            except (CosmicRayTestingException, ValueError):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T223358394246Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T223359279235Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.61s

operator: core/ExceptionReplacer, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -462,7 +462,7 @@
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
-            except (TypeError, ValueError):
+            except (TypeError, CosmicRayTestingException):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T101734331532Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T101735203549Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.47s

operator: core/ExceptionReplacer, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -500,7 +500,7 @@
                     """),
                     {"did": document_id, "uid": int(g.user["id"])},
                 ).all()
-        except Exception:
+        except CosmicRayTestingException:
             app.logger.error(
                 f"Database error in list_versions: {document_id},{g.user['id']}"
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ExceptionReplacer, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -544,7 +544,7 @@
                     ),
                     {"uid": int(g.user["id"])},
                 ).all()
-        except ValueError:
+        except CosmicRayTestingException:
             app.logger.error("Invalid user ID in auth token")
             return jsonify({"error": "Authentication error"}), 401
         except Exception:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ExceptionReplacer, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -547,7 +547,7 @@
         except ValueError:
             app.logger.error("Invalid user ID in auth token")
             return jsonify({"error": "Authentication error"}), 401
-        except Exception:
+        except CosmicRayTestingException:
             app.logger.error(
                 "Database error in list_all_versions for user=%s", g.user["id"]
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ExceptionReplacer, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -576,7 +576,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id)
-            except (TypeError, ValueError):
+            except (CosmicRayTestingException, ValueError):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



document_id = None



    @app.get("/api/get-document")

    @app.get("/api/get-document/<int:document_id>")

    @require_auth

    def get_document(document_id: int | None = None):

        # Support both path param and ?id=/ ?documentid=

        if document_id is None:

            document_id = request.args.get("id") or request.args.get("documentid")

            try:

>               document_id = int(document_id)

                              ^^^^^^^^^^^^^^^^

E               TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'



server.py:578: TypeError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

>       resp = client.get("/api/get-document")

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:301: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = None



    @app.get("/api/get-document")

    @app.get("/api/get-document/<int:document_id>")

    @require_auth

    def get_document(document_id: int | None = None):

        # Support both path param and ?id=/ ?documentid=

        if document_id is None:

            document_id = request.args.get("id") or request.args.get("documentid")

            try:

                document_id = int(document_id)

>           except (CosmicRayTestingException, ValueError):

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

E           NameError: name 'CosmicRayTestingException' is not defined



server.py:579: NameError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - NameError: name 'Cosmic...

1 failed, 41 passed, 23 warnings in 20.99s

operator: core/ExceptionReplacer, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -576,7 +576,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id)
-            except (TypeError, ValueError):
+            except (TypeError, CosmicRayTestingException):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



document_id = None



    @app.get("/api/get-document")

    @app.get("/api/get-document/<int:document_id>")

    @require_auth

    def get_document(document_id: int | None = None):

        # Support both path param and ?id=/ ?documentid=

        if document_id is None:

            document_id = request.args.get("id") or request.args.get("documentid")

            try:

>               document_id = int(document_id)

                              ^^^^^^^^^^^^^^^^

E               TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'



server.py:578: TypeError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

>       resp = client.get("/api/get-document")

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:301: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = None



    @app.get("/api/get-document")

    @app.get("/api/get-document/<int:document_id>")

    @require_auth

    def get_document(document_id: int | None = None):

        # Support both path param and ?id=/ ?documentid=

        if document_id is None:

            document_id = request.args.get("id") or request.args.get("documentid")

            try:

                document_id = int(document_id)

>           except (TypeError, CosmicRayTestingException):

                               ^^^^^^^^^^^^^^^^^^^^^^^^^

E           NameError: name 'CosmicRayTestingException' is not defined



server.py:579: NameError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - NameError: name 'Cosmic...

1 failed, 41 passed, 23 warnings in 21.08s

operator: core/ExceptionReplacer, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -596,7 +596,7 @@
                     ),
                     {"id": document_id, "uid": int(g.user["id"])},
                 ).first()
-        except Exception:
+        except CosmicRayTestingException:
             app.logger.error(
                 f"Database error in get_document: {document_id},{g.user['id']}"
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ExceptionReplacer, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -619,7 +619,7 @@
         try:
             resolved = file_path.resolve()
             resolved.relative_to(storage_root)
-        except Exception:
+        except CosmicRayTestingException:
             # Path looks suspicious or outside storage
             app.logger.warning(
                 "Rejected document path for id %s: %s", document_id, row.path
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ExceptionReplacer, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -633,7 +633,7 @@
         # TOCTOU-safe open and validation
         try:
             f = open(resolved, "rb")
-        except OSError:
+        except CosmicRayTestingException:
             app.logger.error("File missing on disk for document id=%s", document_id)
             return jsonify({"error": "file missing on disk"}), 410
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/ExceptionReplacer, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -681,7 +681,7 @@
             )
 
             return resp
-        except Exception as e:
+        except CosmicRayTestingException as e:
             f.close()
             # Log error and return generic message
             app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/ExceptionReplacer, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -710,7 +710,7 @@
                     ),
                     {"link": link},
                 ).first()
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Database error in get_version: %s", e)
             inc_db_error("get_version")
             return jsonify({"error": "database error"}), 503
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/ExceptionReplacer, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -721,7 +721,7 @@
 
         try:
             resolved = _safe_resolve_under_storage(row.path, app.config["STORAGE_DIR"])
-        except Exception as exc:
+        except CosmicRayTestingException as exc:
             app.logger.warning(
                 "Rejected version path for link %s: %s (%s)", link, row.path, exc
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ExceptionReplacer, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -741,7 +741,7 @@
                     return jsonify({"error": "document not available"}), 415
                 fh.seek(0)
                 last_modified = os.fstat(fh.fileno()).st_mtime
-        except OSError:
+        except CosmicRayTestingException:
             app.logger.error("File missing on disk for version link=%s", link)
             return jsonify({"error": "file missing on disk"}), 410
         except Exception as e:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/ExceptionReplacer, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -744,7 +744,7 @@
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
             return jsonify({"error": "file missing on disk"}), 410
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
             return jsonify({"error": "error serving file"}), 500
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ExceptionReplacer, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -763,7 +763,7 @@
                 max_age=0,
                 last_modified=last_modified,
             )
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Error serving version %s: %s", link, e)
             return jsonify({"error": "error serving file"}), 500
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/ExceptionReplacer, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -791,7 +791,7 @@
         else:
             try:
                 fp.relative_to(storage_root)
-            except ValueError:
+            except CosmicRayTestingException:
                 raise RuntimeError(
                     f"path {fp} escapes storage root {storage_root}"
                 ) from None
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ExceptionReplacer, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -816,7 +816,7 @@
 
         try:
             doc_id = int(document_id)
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ExceptionReplacer, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -816,7 +816,7 @@
 
         try:
             doc_id = int(document_id)
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ExceptionReplacer, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -840,7 +840,7 @@
                     ),
                     {"id": doc_id, "owner": owner_id},
                 ).first()
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_select")
             return jsonify({"error": "database error during delete"}), 503
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ExceptionReplacer, occurrence: 35
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -863,7 +863,7 @@
                 try:
                     fp.unlink()
                     file_deleted = True
-                except Exception as e:
+                except CosmicRayTestingException as e:
                     delete_error = f"failed to delete file: {e}"
                     app.logger.warning(
                         "Failed to delete file %s for doc id=%s: %s", fp, row.id, e
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T184300295833Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T184301186733Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.52s

operator: core/ExceptionReplacer, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -870,7 +870,7 @@
                     )
             else:
                 file_missing = True
-        except RuntimeError as e:
+        except CosmicRayTestingException as e:
             # Path escapes storage root; refuse to touch the file
             delete_error = str(e)
             app.logger.error("Path safety check failed for doc id=%s: %s", row.id, e)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ExceptionReplacer, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -886,7 +886,7 @@
                     text("DELETE FROM Documents WHERE id = :id AND ownerid = :owner"),
                     {"id": doc_id, "owner": owner_id},
                 )
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_delete")
             return jsonify({"error": "database error during delete"}), 503
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ExceptionReplacer, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -916,7 +916,7 @@
             )
         try:
             doc_id = document_id
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ExceptionReplacer, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -916,7 +916,7 @@
             )
         try:
             doc_id = document_id
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ExceptionReplacer, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -936,7 +936,7 @@
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ExceptionReplacer, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -936,7 +936,7 @@
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if (
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.67s

operator: core/ExceptionReplacer, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -964,7 +964,7 @@
                     ),
                     {"id": doc_id, "owner": int(g.user["id"])},
                 ).first()
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error("Database error fetching document %s", e)
             return jsonify({"error": "database error"}), 503
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ExceptionReplacer, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -982,7 +982,7 @@
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
-        except ValueError:
+        except CosmicRayTestingException:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ExceptionReplacer, occurrence: 44
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1002,7 +1002,7 @@
                     doc_id,
                 )
                 return jsonify({"error": "watermarking method not applicable"}), 400
-        except Exception as e:
+        except CosmicRayTestingException as e:
             inc_watermark_failed(method, "applicability_exception")
             app.logger.error(
                 "Watermark applicability check failed for document %s: %s", doc_id, e
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



method = 'watermarkmethod'



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if isinstance(method, WatermarkingMethod):

            return method

        try:

>           return METHODS[method]

                   ^^^^^^^^^^^^^^^

E           KeyError: 'watermarkmethod'



watermarking_utils.py:79: KeyError



The above exception was the direct cause of the following exception:



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

>           applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )



server.py:994: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:112: in is_watermarking_applicable

    m = get_method(method)

        ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



method = 'watermarkmethod'



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if isinstance(method, WatermarkingMethod):

            return method

        try:

            return METHODS[method]

        except KeyError as exc:

>           raise KeyError(

                f"Unknown watermarking method: {method!r}. Known: {sorted(METHODS)}"

            ) from exc

E           KeyError: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"



watermarking_utils.py:81: KeyError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

>       resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})



..\test\test_api.py:359: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

>       except CosmicRayTestingException as e:

               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       NameError: name 'CosmicRayTestingException' is not defined



server.py:1005: NameError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - NameError: name 'Co...

1 failed, 41 passed, 23 warnings in 22.13s

operator: core/ExceptionReplacer, occurrence: 45
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1029,7 +1029,7 @@
                     method,
                 )
                 return jsonify({"error": "watermarking produced no output"}), 500
-        except Exception as e:
+        except CosmicRayTestingException as e:
             inc_watermark_failed(method, "exception")
             app.logger.error(
                 "Watermarking failed for document %s using method %s: %s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/ExceptionReplacer, occurrence: 46
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1052,7 +1052,7 @@
         try:
             with dest_path.open("wb") as f:
                 f.write(wm_bytes)
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error(
                 "Failed to write watermarked file %s for document %s: %s",
                 dest_path,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ExceptionReplacer, occurrence: 47
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1086,7 +1086,7 @@
                     },
                 )
                 vid = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())
-        except IntegrityError as ie:
+        except CosmicRayTestingException as ie:
             # This should be very rare due to SHA-256 usage, but handle it just in case
             try:
                 dest_path.unlink(missing_ok=True)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



self = <sqlalchemy.engine.base.Connection object at 0x0000023365611400>

dialect = <sqlalchemy.dialects.mysql.pymysql.MySQLDialect_pymysql object at 0x000002336A2371D0>

context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqldb object at 0x000002336A1E6DE0>

statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb object at 0x000002336A2361B0>

parameters = [{'documentid': 1, 'intended_for': 'Mickey Mouse', 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'method': 'robust-xmp', ...}]



    def _exec_single_context(

        self,

        dialect: Dialect,

        context: ExecutionContext,

        statement: Union[str, Compiled],

        parameters: Optional[_AnyMultiExecuteParams],

    ) -> CursorResult[Any]:

        """continue the _execute_context() method for a single DBAPI

        cursor.execute() or cursor.executemany() call.

    

        """

        if dialect.bind_typing is BindTyping.SETINPUTSIZES:

            generic_setinputsizes = context._prepare_set_input_sizes()

    

            if generic_setinputsizes:

                try:

                    dialect.do_set_input_sizes(

                        context.cursor, generic_setinputsizes, context

                    )

                except BaseException as e:

                    self._handle_dbapi_exception(

                        e, str(statement), parameters, None, context

                    )

    

        cursor, str_statement, parameters = (

            context.cursor,

            context.statement,

            context.parameters,

        )

    

        effective_parameters: Optional[_AnyExecuteParams]

    

        if not context.executemany:

            effective_parameters = parameters[0]

        else:

            effective_parameters = parameters

    

        if self._has_events or self.engine._has_events:

            for fn in self.dispatch.before_cursor_execute:

                str_statement, effective_parameters = fn(

                    self,

                    cursor,

                    str_statement,

                    effective_parameters,

                    context,

                    context.executemany,

                )

    

        if self._echo:

            self._log_info(str_statement)

    

            stats = context._get_cache_stats()

    

            if not self.engine.hide_parameters:

                self._log_info(

                    "[%s] %r",

                    stats,

                    sql_util._repr_params(

                        effective_parameters,

                        batches=10,

                        ismulti=context.executemany,

                    ),

                )

            else:

                self._log_info(

                    "[%s] [SQL parameters hidden due to hide_parameters=True]",

                    stats,

                )

    

        evt_handled: bool = False

        try:

            if context.execute_style is ExecuteStyle.EXECUTEMANY:

                effective_parameters = cast(

                    "_CoreMultiExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_executemany:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_executemany(

                        cursor,

                        str_statement,

                        effective_parameters,

                        context,

                    )

            elif not effective_parameters and context.no_parameters:

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute_no_params:

                        if fn(cursor, str_statement, context):

                            evt_handled = True

                            break

                if not evt_handled:

                    self.dialect.do_execute_no_params(

                        cursor, str_statement, context

                    )

            else:

                effective_parameters = cast(

                    "_CoreSingleExecuteParams", effective_parameters

                )

                if self.dialect._has_events:

                    for fn in self.dialect.dispatch.do_execute:

                        if fn(

                            cursor,

                            str_statement,

                            effective_parameters,

                            context,

                        ):

                            evt_handled = True

                            break

                if not evt_handled:

>                   self.dialect.do_execute(

                        cursor, str_statement, effective_parameters, context

                    )



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b"\xff&\x04#23000Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'"



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       pymysql.err.IntegrityError: (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



The above exception was the direct cause of the following exception:



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

        dest_path = dest_dir / candidate

    

        # write bytes

        try:

            with dest_path.open("wb") as f:

                f.write(wm_bytes)

        except Exception as e:

            app.logger.error(

                "Failed to write watermarked file %s for document %s: %s",

                dest_path,

                doc_id,

                e,

            )

            return jsonify({"error": "failed to write watermarked file"}), 500

    

        # link token = sha256(watermarked_file_name) - using stronger hash

        link_token = hashlib.sha256(candidate.encode("utf-8")).hexdigest()

    

        try:

            with get_engine().begin() as conn:

>               conn.execute(

                    text(

                        """

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (:documentid, :link, :intended_for, :secret,

                               :method, :position, :path)

                    """

                    ),

                    {

                        "documentid": doc_id,

                        "link": link_token,

                        "intended_for": intended_for,

                        "secret": secret,

                        "method": method,

                        "position": position or "",

                        "path": str(dest_path),

                    },

                )



server.py:1069: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1419: in execute

    return meth(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\sql\elements.py:526: in _execute_on_connection

    return connection._execute_clauseelement(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1641: in _execute_clauseelement

    ret = self._execute_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1846: in _execute_context

    return self._exec_single_context(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1986: in _exec_single_context

    self._handle_dbapi_exception(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:2355: in _handle_dbapi_exception

    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:1967: in _exec_single_context

    self.dialect.do_execute(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:951: in do_execute

    cursor.execute(statement, parameters)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:153: in execute

    result = self._query(query)

             ^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\cursors.py:322: in _query

    conn.query(q)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:575: in query

    self._affected_rows = self._read_query_result(unbuffered=unbuffered)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:826: in _read_query_result

    result.read()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:1203: in read

    first_packet = self.connection._read_packet()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\connections.py:782: in _read_packet

    packet.raise_for_error()

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\protocol.py:219: in raise_for_error

    err.raise_mysql_exception(self._data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



data = b"\xff&\x04#23000Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'"



    def raise_mysql_exception(data):

        errno = struct.unpack("<h", data[1:3])[0]

        # https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html

        # Error packet has optional sqlstate that is 5 bytes and starts with '#'.

        if data[3] == 0x23:  # '#'

            # sqlstate = data[4:9].decode()

            # TODO: Append (sqlstate) in the error message. This will be come in next minor release.

            errval = data[9:].decode("utf-8", "replace")

        else:

            errval = data[3:].decode("utf-8", "replace")

        errorclass = error_map.get(errno)

        if errorclass is None:

            errorclass = InternalError if errno < 1000 else OperationalError

>       raise errorclass(errno, errval)

E       sqlalchemy.exc.IntegrityError: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

E       [SQL: 

E                               INSERT INTO Versions (documentid, link, intended_for,

E                                                   secret, method, position, path)

E                               VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

E                                      %(method)s, %(position)s, %(path)s)

E                           ]

E       [parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

E       (Background on this error at: https://sqlalche.me/e/20/gkpj)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymysql\err.py:150: IntegrityError



During handling of the above exception, another exception occurred:



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

>       resp = client.post("/api/create-watermark", json=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:356: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:103: in wrapper

    return f(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



document_id = 1



    @app.post("/api/create-watermark")

    @app.post("/api/create-watermark/<int:document_id>")

    @require_auth

    def create_watermark(document_id: int | None = None):

        # accept id from path, query (?id= / ?documentid=), or JSON body on GET

        if not document_id:

            document_id = (

                request.args.get("id")

                or request.args.get("documentid")

                or (request.is_json and (request.get_json(silent=True) or {}).get("id"))

            )

        try:

            doc_id = document_id

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id in query: %s", document_id)

            return jsonify({"error": "document id required"}), 400

    

        payload = request.get_json(silent=True) or {}

        # allow a couple of aliases for convenience

        method = payload.get("method")

        intended_for = payload.get("intended_for")

        position = payload.get("position") or None

        secret = payload.get("secret")

        key = payload.get("key")

    

        # validate input

        try:

            if doc_id is None:

                app.logger.warning("Missing document id in request")

                return jsonify({"error": "document_id (int) is required"}), 400

            doc_id = int(doc_id)

            if doc_id <= 0 or doc_id > MAX_DB_INT:

                return jsonify({"error": "document_id (int) is required"}), 400

        except (TypeError, ValueError):

            app.logger.warning("Invalid document id: %s", document_id)

            return jsonify({"error": "document_id (int) is required"}), 400

        if (

            not method

            or not intended_for

            or not isinstance(secret, str)

            or not isinstance(key, str)

        ):

            app.logger.warning("Missing required fields for watermarking: %s", payload)

            return jsonify(

                {"error": "method, intended_for, secret, and key are required"}

            ), 400

    

        # lookup the document; enforce ownership

        try:

            with get_engine().connect() as conn:

                row = conn.execute(

                    text(

                        """

                        SELECT id, name, path

                        FROM Documents

                        WHERE id = :id AND ownerid = :owner

                        LIMIT 1

                    """

                    ),

                    {"id": doc_id, "owner": int(g.user["id"])},

                ).first()

        except Exception as e:

            app.logger.error("Database error fetching document %s", e)

            return jsonify({"error": "database error"}), 503

    

        if not row:

            app.logger.warning(

                "Document not found or access denied for watermarking id=%s", doc_id

            )

            return jsonify({"error": "document not found"}), 404

    

        # resolve path safely under STORAGE_DIR

        storage_root = Path(app.config["STORAGE_DIR"]).resolve()

        file_path = Path(row.path)

        if not file_path.is_absolute():

            file_path = storage_root / file_path

        file_path = file_path.resolve()

        try:

            file_path.relative_to(storage_root)

        except ValueError:

            app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)

            return jsonify({"error": "document path invalid"}), 500

        if not file_path.exists():

            app.logger.error("File missing on disk for document id=%s", doc_id)

            return jsonify({"error": "file missing on disk"}), 410

    

        # check watermark applicability

        try:

            applicable = WMUtils.is_watermarking_applicable(

                method=method, pdf=str(file_path), position=position

            )

            if applicable is False:

                inc_watermark_failed(method, "applicability")

                app.logger.info(

                    "Watermarking method %s not applicable for document %s",

                    method,

                    doc_id,

                )

                return jsonify({"error": "watermarking method not applicable"}), 400

        except Exception as e:

            inc_watermark_failed(method, "applicability_exception")

            app.logger.error(

                "Watermark applicability check failed for document %s: %s", doc_id, e

            )

            return jsonify({"error": "watermark applicability check failed"}), 400

    

        # apply watermark \u2192 bytes

        try:

            _wm_start = time.time()

            wm_bytes: bytes = WMUtils.apply_watermark(

                pdf=str(file_path),

                secret=secret,

                key=key,

                method=method,

                intended_for=intended_for,

                position=position,

            )

            observe_watermark_duration(method, time.time() - _wm_start)

            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:

                inc_watermark_failed(method, "empty_output")

                app.logger.error(

                    "Watermarking produced no output for document %s using method %s",

                    doc_id,

                    method,

                )

                return jsonify({"error": "watermarking produced no output"}), 500

        except Exception as e:

            inc_watermark_failed(method, "exception")

            app.logger.error(

                "Watermarking failed for document %s using method %s: %s",

                doc_id,

                method,

                e,

            )

            return jsonify({"error": "watermarking failed"}), 500

    

        # build destination file name: "<original_name>__<intended_to>.pdf"

        base_name = Path(row.name or file_path.name).stem

        intended_slug = secure_filename(intended_for)

        dest_dir = file_path.parent / "watermarks"

        dest_dir.mkdir(parents=True, exist_ok=True)

    

        candidate = f"{base_name}__{intended_slug}.pdf"

        dest_path = dest_dir / candidate

    

        # write bytes

        try:

            with dest_path.open("wb") as f:

                f.write(wm_bytes)

        except Exception as e:

            app.logger.error(

                "Failed to write watermarked file %s for document %s: %s",

                dest_path,

                doc_id,

                e,

            )

            return jsonify({"error": "failed to write watermarked file"}), 500

    

        # link token = sha256(watermarked_file_name) - using stronger hash

        link_token = hashlib.sha256(candidate.encode("utf-8")).hexdigest()

    

        try:

            with get_engine().begin() as conn:

                conn.execute(

                    text(

                        """

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (:documentid, :link, :intended_for, :secret,

                               :method, :position, :path)

                    """

                    ),

                    {

                        "documentid": doc_id,

                        "link": link_token,

                        "intended_for": intended_for,

                        "secret": secret,

                        "method": method,

                        "position": position or "",

                        "path": str(dest_path),

                    },

                )

                vid = int(conn.execute(text("SELECT LAST_INSERT_ID()")).scalar())

>       except CosmicRayTestingException as ie:

               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       NameError: name 'CosmicRayTestingException' is not defined



server.py:1089: NameError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - NameError: name 'Co...

1 failed, 41 passed, 23 warnings in 21.24s

operator: core/ExceptionReplacer, occurrence: 48
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1090,7 +1090,7 @@
             # This should be very rare due to SHA-256 usage, but handle it just in case
             try:
                 dest_path.unlink(missing_ok=True)
-            except Exception as cleanup_error:
+            except CosmicRayTestingException as cleanup_error:
                 app.logger.warning(
                     f"Failed to cleanup file {dest_path}: {cleanup_error}"
                 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ExceptionReplacer, occurrence: 49
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1099,7 +1099,7 @@
             )
             inc_db_error("insert_version")
             return jsonify({"error": "database error during version insert"}), 503
-        except Exception:
+        except CosmicRayTestingException:
             try:
                 dest_path.unlink(missing_ok=True)
             except Exception as cleanup_error:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.66s

operator: core/ExceptionReplacer, occurrence: 50
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1102,7 +1102,7 @@
         except Exception:
             try:
                 dest_path.unlink(missing_ok=True)
-            except Exception as cleanup_error:
+            except CosmicRayTestingException as cleanup_error:
                 app.logger.warning(
                     f"Failed to cleanup file {dest_path}: {cleanup_error}"
                 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ExceptionReplacer, occurrence: 51
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1153,7 +1153,7 @@
             )
         try:
             doc_id = document_id
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ExceptionReplacer, occurrence: 52
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1153,7 +1153,7 @@
             )
         try:
             doc_id = document_id
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id in query: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ExceptionReplacer, occurrence: 53
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1171,7 +1171,7 @@
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
-        except (TypeError, ValueError):
+        except (CosmicRayTestingException, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if not method or not isinstance(method, str) or not isinstance(key, str):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ExceptionReplacer, occurrence: 54
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1171,7 +1171,7 @@
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
-        except (TypeError, ValueError):
+        except (TypeError, CosmicRayTestingException):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
         if not method or not isinstance(method, str) or not isinstance(key, str):
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133957473413Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133958350057Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.38s

operator: core/ExceptionReplacer, occurrence: 55
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1192,7 +1192,7 @@
                     ),
                     {"id": doc_id, "owner": int(g.user["id"])},
                 ).first()
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error(
                 "Database error fetching document %s for watermark read: %s", doc_id, e
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ExceptionReplacer, occurrence: 56
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1212,7 +1212,7 @@
         file_path = file_path.resolve()
         try:
             file_path.relative_to(storage_root)
-        except ValueError:
+        except CosmicRayTestingException:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.26s

operator: core/ExceptionReplacer, occurrence: 57
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1222,7 +1222,7 @@
         secret = None
         try:
             secret = WMUtils.read_watermark(method=method, pdf=str(file_path), key=key)
-        except Exception as e:
+        except CosmicRayTestingException as e:
             app.logger.error(
                 "Error when attempting to read watermark for document %s: %s", doc_id, e
             )
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123507545257Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T123508525133Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = ( 3**63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = ( 1**63) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
.....F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:824 Non-positive document id for deletion: 2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 400 == 200

5 failed, 37 passed, 23 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2** 64) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.70s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2** 62) - 1
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.26s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) - 2
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.70s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -31,7 +31,7 @@
     render_prometheus,
 )
 
-MAX_DB_INT = (2**63) - 1
+MAX_DB_INT = (2**63) - 0
 
 RMAPHandler = None  # default
 if not os.environ.get("TATOU_TEST_DISABLE_RMAP"):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -91,7 +91,7 @@
     def _serializer():
         return URLSafeTimedSerializer(app.config["SECRET_KEY"], salt="ljkdsad123123kjd")
 
-    def _auth_error(msg: str, code: int = 401):
+    def _auth_error(msg: str, code: int = 402):
         app.logger.warning("Auth error (%s): %s", code, msg)
         return jsonify({"error": msg}), code
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -91,7 +91,7 @@
     def _serializer():
         return URLSafeTimedSerializer(app.config["SECRET_KEY"], salt="ljkdsad123123kjd")
 
-    def _auth_error(msg: str, code: int = 401):
+    def _auth_error(msg: str, code: int = 400):
         app.logger.warning("Auth error (%s): %s", code, msg)
         return jsonify({"error": msg}), code
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T182010066186Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T182010937404Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.60s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -99,7 +99,7 @@
         @wraps(f)
         def wrapper(*args, **kwargs):
             if app.config['TESTING']:
-                g.user = {"id": 1, "login": "username", "email": "user@email.se"}
+                g.user = {"id": 2, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T191601087429Z__input.pdf user=2

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T191602123059Z__watermarked.pdf user=2

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.48s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -99,7 +99,7 @@
         @wraps(f)
         def wrapper(*args, **kwargs):
             if app.config['TESTING']:
-                g.user = {"id": 1, "login": "username", "email": "user@email.se"}
+                g.user = {"id": 0, "login": "username", "email": "user@email.se"}
                 return f(*args, **kwargs)
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
...F.FFF.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T134821799431Z__input.pdf user=0

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 35 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:530 Missing user info in auth token

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T134822833522Z__watermarked.pdf user=0

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 401 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

7 failed, 35 passed, 23 warnings in 20.49s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -104,7 +104,7 @@
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
-            token = auth.split(" ", 1)[1].strip()
+            token = auth.split(" ", 2)[1].strip()
             try:
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T181203089438Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T181203958887Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.34s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -104,7 +104,7 @@
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
-            token = auth.split(" ", 1)[1].strip()
+            token = auth.split(" ", 0)[1].strip()
             try:
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T221931831441Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T221932665734Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.47s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -104,7 +104,7 @@
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
-            token = auth.split(" ", 1)[1].strip()
+            token = auth.split(" ", 1)[ 2].strip()
             try:
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T104112479399Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T104113327872Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -104,7 +104,7 @@
             auth = request.headers.get("Authorization", "")
             if not auth.startswith("Bearer "):
                 return _auth_error("Missing or invalid Authorization header")
-            token = auth.split(" ", 1)[1].strip()
+            token = auth.split(" ", 1)[ 0].strip()
             try:
                 data = _serializer().loads(
                     token, max_age=app.config["TOKEN_TTL_SECONDS"]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read( 1025 * 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read( 1023 * 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 * 1025), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in iter(lambda: f.read(1024 * 1023), b""):
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -180,7 +180,7 @@
             db_ok = False
         return jsonify(
             {"message": "The server is up and running.", "db_connected": db_ok}
-        ), 200
+        ), 201
 
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
F.........................................                               [100%]

================================== FAILURES ===================================

_____________________________ test_healthz_route ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_healthz_route(client):

        """Test the health check endpoint."""

        resp = client.get("/healthz")

    

>       assert resp.status_code == 200  # nosec B101

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:60: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_healthz_route - assert 201 == 200

1 failed, 41 passed, 23 warnings in 21.64s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -180,7 +180,7 @@
             db_ok = False
         return jsonify(
             {"message": "The server is up and running.", "db_connected": db_ok}
-        ), 200
+        ), 199
 
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
F.........................................                               [100%]

================================== FAILURES ===================================

_____________________________ test_healthz_route ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_healthz_route(client):

        """Test the health check endpoint."""

        resp = client.get("/healthz")

    

>       assert resp.status_code == 200  # nosec B101

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:60: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_healthz_route - assert 199 == 200

1 failed, 41 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 321 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 319 or len(login) > 64:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) > 65:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T174815548727Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T174816445125Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.55s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -185,7 +185,7 @@
     # Extra backend validation for user input
     def validate_user_input(email: str, login: str) -> tuple[bool, str]:
         """Validate user input before database operations"""
-        if len(email) > 320 or len(login) > 64:
+        if len(email) > 320 or len(login) > 63:
             return False, "Email or login too long"
         if not re.match(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", email):
             return False, "Invalid email format"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -203,7 +203,7 @@
         start_db = time.time()
         if not email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
-            return jsonify({"error": "email, login, and password are required"}), 400
+            return jsonify({"error": "email, login, and password are required"}), 401
 
         hpw = generate_password_hash(password)
 
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 201  # Endpoint should exist

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("id"), int)

        assert isinstance(resp_data.get("login"), str)

        assert isinstance(resp_data.get("email"), str)

        #check values are what we submitted

        assert resp_data.get("login") == parameters["login"]

        assert resp_data.get("email") == parameters["email"]

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/create-user",json={

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:93: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'login': 'username', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -203,7 +203,7 @@
         start_db = time.time()
         if not email or not login or not password:
             app.logger.warning("Missing fields in user creation: %s", payload)
-            return jsonify({"error": "email, login, and password are required"}), 400
+            return jsonify({"error": "email, login, and password are required"}), 399
 
         hpw = generate_password_hash(password)
 
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 201  # Endpoint should exist

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("id"), int)

        assert isinstance(resp_data.get("login"), str)

        assert isinstance(resp_data.get("email"), str)

        #check values are what we submitted

        assert resp_data.get("login") == parameters["login"]

        assert resp_data.get("email") == parameters["email"]

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/create-user",json={

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:93: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'login': 'username', 'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -211,7 +211,7 @@
             is_valid, error_msg = validate_user_input(email, login)
             if not is_valid:
                 app.logger.warning("User input validation failed: %s", error_msg)
-                return jsonify({"error": error_msg}), 400
+                return jsonify({"error": error_msg}), 401
 
             with get_engine().begin() as conn:
                 res = conn.execute(
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 201  # Endpoint should exist

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("id"), int)

        assert isinstance(resp_data.get("login"), str)

        assert isinstance(resp_data.get("email"), str)

        #check values are what we submitted

        assert resp_data.get("login") == parameters["login"]

        assert resp_data.get("email") == parameters["email"]

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/create-user",json={

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

        assert resp.status_code == 400

    

        # Missing login

        resp = client.post("/api/create-user",

                json={"email": "user@email.se", "password": "password"},

        )

        assert resp.status_code == 400

    

        # Missing password

        resp = client.post(

        "/api/create-user", json={"email": "user@email.se", "login": "username"}

        )

        assert resp.status_code == 400

    

        # Malformed email

        resp = client.post("/api/create-user",json={

                    "email": "malformedemail",

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:114: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'login': 'username', 'password': 'password'}

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'password': 'password'}

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username'}

WARNING  server:server.py:213 User input validation failed: Invalid email format

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -211,7 +211,7 @@
             is_valid, error_msg = validate_user_input(email, login)
             if not is_valid:
                 app.logger.warning("User input validation failed: %s", error_msg)
-                return jsonify({"error": error_msg}), 400
+                return jsonify({"error": error_msg}), 399
 
             with get_engine().begin() as conn:
                 res = conn.execute(
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 201  # Endpoint should exist

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("id"), int)

        assert isinstance(resp_data.get("login"), str)

        assert isinstance(resp_data.get("email"), str)

        #check values are what we submitted

        assert resp_data.get("login") == parameters["login"]

        assert resp_data.get("email") == parameters["email"]

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/create-user",json={

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

        assert resp.status_code == 400

    

        # Missing login

        resp = client.post("/api/create-user",

                json={"email": "user@email.se", "password": "password"},

        )

        assert resp.status_code == 400

    

        # Missing password

        resp = client.post(

        "/api/create-user", json={"email": "user@email.se", "login": "username"}

        )

        assert resp.status_code == 400

    

        # Malformed email

        resp = client.post("/api/create-user",json={

                    "email": "malformedemail",

                    "login": "username",

                    "password": "password",

                },  # pragma: allowlist secret

        )

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:114: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:205 Missing fields in user creation: {'login': 'username', 'password': 'password'}

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'password': 'password'}

WARNING  server:server.py:205 Missing fields in user creation: {'email': 'user@email.se', 'login': 'username'}

WARNING  server:server.py:213 User input validation failed: Invalid email format

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 21.13s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -231,7 +231,7 @@
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
             )
-            return jsonify({"error": "email or login already exists"}), 409
+            return jsonify({"error": "email or login already exists"}), 410
         except Exception as e:
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.70s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -231,7 +231,7 @@
             app.logger.warning(
                 "Attempt to create duplicate user: email=%s, login=%s", email, login
             )
-            return jsonify({"error": "email or login already exists"}), 409
+            return jsonify({"error": "email or login already exists"}), 408
         except Exception as e:
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -234,7 +234,7 @@
             return jsonify({"error": "email or login already exists"}), 409
         except Exception as e:
             app.logger.error("Database error in create_user: %s", e)
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 504
 
         return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -234,7 +234,7 @@
             return jsonify({"error": "email or login already exists"}), 409
         except Exception as e:
             app.logger.error("Database error in create_user: %s", e)
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 502
 
         return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.18s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -236,7 +236,7 @@
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
 
-        return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
+        return jsonify({"id": row.id, "email": row.email, "login": row.login}), 202
 
     # POST /api/login {login, password}
     @app.post("/api/login")
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 202 == 201

E        +  where 202 = <WrapperTestResponse 52 bytes [202 ACCEPTED]>.status_code



..\test\test_api.py:76: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 202 == 201

1 failed, 41 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -236,7 +236,7 @@
             app.logger.error("Database error in create_user: %s", e)
             return jsonify({"error": "database error"}), 503
 
-        return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
+        return jsonify({"id": row.id, "email": row.email, "login": row.login}), 200
 
     # POST /api/login {login, password}
     @app.post("/api/login")
.F........................................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 200 == 201

E        +  where 200 = <WrapperTestResponse 52 bytes [200 OK]>.status_code



..\test\test_api.py:76: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 200 == 201

1 failed, 41 passed, 23 warnings in 21.55s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -247,7 +247,7 @@
 
         if not email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
-            return jsonify({"error": "email and password are required"}), 400
+            return jsonify({"error": "email and password are required"}), 401
 
         start_db = time.time()
         try:
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("token"), str)

        assert isinstance(resp_data.get("token_type"), str)

        assert isinstance(resp_data.get("expires_in"), int)

        #check val

        assert resp_data.get("token_type") == "bearer"

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/login", json={"password": "password"})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:141: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -247,7 +247,7 @@
 
         if not email or not password:
             app.logger.warning("Missing fields in login attempt: %s", payload)
-            return jsonify({"error": "email and password are required"}), 400
+            return jsonify({"error": "email and password are required"}), 399
 
         start_db = time.time()
         try:
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("token"), str)

        assert isinstance(resp_data.get("token_type"), str)

        assert isinstance(resp_data.get("expires_in"), int)

        #check val

        assert resp_data.get("token_type") == "bearer"

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/login", json={"password": "password"})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:141: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'password': 'password'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 36
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -274,7 +274,7 @@
                         email if email else "<empty>",
                     )
                     inc_login_failure("invalid_credentials")
-                    return jsonify({"error": "invalid credentials"}), 401
+                    return jsonify({"error": "invalid credentials"}), 402
 
         except Exception as e:
             app.logger.error("Database error in login: %s", e)
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("token"), str)

        assert isinstance(resp_data.get("token_type"), str)

        assert isinstance(resp_data.get("expires_in"), int)

        #check val

        assert resp_data.get("token_type") == "bearer"

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/login", json={"password": "password"})

        assert resp.status_code == 400

        # Missing password

        resp = client.post("/api/login", json={"email": "user@email.se"})

        assert resp.status_code == 400

        # Both missing

        resp = client.post("/api/login", json={})

        assert resp.status_code == 400

        # Malformed email - counts as non existing

        resp = client.post("/api/login", json={"email": "malformedemail", "password": "password"})

>       assert resp.status_code == 401

E       assert 402 == 401

E        +  where 402 = <WrapperTestResponse streamed [402 PAYMENT REQUIRED]>.status_code



..\test\test_api.py:150: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'password': 'password'}

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se'}

WARNING  server:server.py:249 Missing fields in login attempt: {}

WARNING  server:server.py:272 Failed login attempt for email: malformedemail

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 402 == 401

1 failed, 41 passed, 23 warnings in 21.29s

operator: core/NumberReplacer, occurrence: 37
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -274,7 +274,7 @@
                         email if email else "<empty>",
                     )
                     inc_login_failure("invalid_credentials")
-                    return jsonify({"error": "invalid credentials"}), 401
+                    return jsonify({"error": "invalid credentials"}), 400
 
         except Exception as e:
             app.logger.error("Database error in login: %s", e)
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        assert isinstance(resp_data.get("token"), str)

        assert isinstance(resp_data.get("token_type"), str)

        assert isinstance(resp_data.get("expires_in"), int)

        #check val

        assert resp_data.get("token_type") == "bearer"

    

        #Test with missing parameters

        # Missing email

        resp = client.post("/api/login", json={"password": "password"})

        assert resp.status_code == 400

        # Missing password

        resp = client.post("/api/login", json={"email": "user@email.se"})

        assert resp.status_code == 400

        # Both missing

        resp = client.post("/api/login", json={})

        assert resp.status_code == 400

        # Malformed email - counts as non existing

        resp = client.post("/api/login", json={"email": "malformedemail", "password": "password"})

>       assert resp.status_code == 401

E       assert 400 == 401

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:150: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:249 Missing fields in login attempt: {'password': 'password'}

WARNING  server:server.py:249 Missing fields in login attempt: {'email': 'user@email.se'}

WARNING  server:server.py:249 Missing fields in login attempt: {}

WARNING  server:server.py:272 Failed login attempt for email: malformedemail

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 400 == 401

1 failed, 41 passed, 23 warnings in 21.54s

operator: core/NumberReplacer, occurrence: 38
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -279,7 +279,7 @@
         except Exception as e:
             app.logger.error("Database error in login: %s", e)
             inc_db_error("login_select")
-            return jsonify({"error": "An error occurred"}), 503
+            return jsonify({"error": "An error occurred"}), 504
 
         observe_db_latency("login_select", time.time() - start_db)
         token = _serializer().dumps(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/NumberReplacer, occurrence: 39
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -279,7 +279,7 @@
         except Exception as e:
             app.logger.error("Database error in login: %s", e)
             inc_db_error("login_select")
-            return jsonify({"error": "An error occurred"}), 503
+            return jsonify({"error": "An error occurred"}), 502
 
         observe_db_latency("login_select", time.time() - start_db)
         token = _serializer().dumps(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 40
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -292,7 +292,7 @@
                 "token_type": "bearer",
                 "expires_in": app.config["TOKEN_TTL_SECONDS"],
             }
-        ), 200
+        ), 201
 
     # POST /api/upload-document  (multipart/form-data)
     @app.post("/api/upload-document")
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 159 bytes [201 CREATED]>.status_code



..\test\test_api.py:129: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 201 == 200

1 failed, 41 passed, 23 warnings in 21.50s

operator: core/NumberReplacer, occurrence: 41
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -292,7 +292,7 @@
                 "token_type": "bearer",
                 "expires_in": app.config["TOKEN_TTL_SECONDS"],
             }
-        ), 200
+        ), 199
 
     # POST /api/upload-document  (multipart/form-data)
     @app.post("/api/upload-document")
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

>       resp_data = resp.get_json()

                    ^^^^^^^^^^^^^^^



..\test\test_api.py:124: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\response.py:620: in get_json

    return self.json_module.loads(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\json\provider.py:187: in loads

    return json.loads(s, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py:346: in loads

    return _default_decoder.decode(s)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:337: in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <json.decoder.JSONDecoder object at 0x0000023BCDD012B0>, s = '', idx = 0



    def raw_decode(self, s, idx=0):

        """Decode a JSON document from ``s`` (a ``str`` beginning with

        a JSON document) and return a 2-tuple of the Python

        representation and the index in ``s`` where the document ended.

    

        This can be used to decode a JSON document from a string that may

        have extraneous data at the end.

    

        """

        try:

            obj, end = self.scan_once(s, idx)

        except StopIteration as err:

>           raise JSONDecodeError("Expecting value", s, err.value) from None

E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:355: JSONDecodeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - json.decoder.JSONDecodeError: ...

1 failed, 41 passed, 23 warnings in 21.30s

operator: core/NumberReplacer, occurrence: 42
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -301,7 +301,7 @@
         if "file" not in request.files:
             inc_suspicious("upload_missing_file_field")
             app.logger.warning("Upload attempt missing 'file' field")
-            return jsonify({"error": "file is required (multipart/form-data)"}), 400
+            return jsonify({"error": "file is required (multipart/form-data)"}), 401
 
         file = request.files["file"]
         if not file or file.filename == "":
...F......................................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:180: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 43
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -301,7 +301,7 @@
         if "file" not in request.files:
             inc_suspicious("upload_missing_file_field")
             app.logger.warning("Upload attempt missing 'file' field")
-            return jsonify({"error": "file is required (multipart/form-data)"}), 400
+            return jsonify({"error": "file is required (multipart/form-data)"}), 399
 
         file = request.files["file"]
         if not file or file.filename == "":
...F......................................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:180: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 20.43s

operator: core/NumberReplacer, occurrence: 44
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -306,7 +306,7 @@
         file = request.files["file"]
         if not file or file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
-            return jsonify({"error": "empty filename"}), 400
+            return jsonify({"error": "empty filename"}), 401
 
         start_db = time.time()
         # Validate file size
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.63s

operator: core/NumberReplacer, occurrence: 45
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -306,7 +306,7 @@
         file = request.files["file"]
         if not file or file.filename == "":
             app.logger.warning("Upload attempt with empty filename")
-            return jsonify({"error": "empty filename"}), 400
+            return jsonify({"error": "empty filename"}), 399
 
         start_db = time.time()
         # Validate file size
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 46
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 51 * 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x00000259FD9A0780>('id')

E            +    where <built-in method get of dict object at 0x00000259FD9A0780> = {'creation': '2025-10-17T15:58:40.312082', 'id': 3, 'name': 'Water File', 'sha256': '70E80023CAE0AB25227E6F011B7038B7E1F6BDD7AA1D3043E30223BCA945E768', ...}.get



..\test\test_api.py:405: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 40 passed, 23 warnings in 21.33s

operator: core/NumberReplacer, occurrence: 47
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 49 * 1024 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 48
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1025 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x00000199647377C0>('id')

E            +    where <built-in method get of dict object at 0x00000199647377C0> = {'creation': '2025-10-17T14:29:37.564501', 'id': 3, 'name': 'Water File', 'sha256': '70E80023CAE0AB25227E6F011B7038B7E1F6BDD7AA1D3043E30223BCA945E768', ...}.get



..\test\test_api.py:405: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 40 passed, 23 warnings in 21.19s

operator: core/NumberReplacer, occurrence: 49
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1023 * 1024  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 50
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 * 1025  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 201 == 413

E            +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

>           assert upload_resp_data.get("id") == 2

E           AssertionError: assert 3 == 2

E            +  where 3 = <built-in method get of dict object at 0x000001A3A75A6280>('id')

E            +    where <built-in method get of dict object at 0x000001A3A75A6280> = {'creation': '2025-10-17T12:10:09.452451', 'id': 3, 'name': 'Water File', 'sha256': '70E80023CAE0AB25227E6F011B7038B7E1F6BDD7AA1D3043E30223BCA945E768', ...}.get



..\test\test_api.py:405: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 201 == 413

FAILED ..\test\test_api.py::test_read_watermark_route - AssertionError: asser...

2 failed, 40 passed, 23 warnings in 21.74s

operator: core/NumberReplacer, occurrence: 51
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -310,7 +310,7 @@
 
         start_db = time.time()
         # Validate file size
-        MAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB
+        MAX_FILE_SIZE = 50 * 1024 * 1023  # 50MB
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/NumberReplacer, occurrence: 52
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -314,7 +314,7 @@
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
-            return jsonify({"error": "file too large"}), 413
+            return jsonify({"error": "file too large"}), 414
 
         # Validate file type and MIME type
         if file.mimetype != "application/pdf":
...F......................................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 414 == 413

E            +  where 414 = <WrapperTestResponse streamed [414 REQUEST URI TOO LONG]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

WARNING  server:server.py:316 Upload attempt with oversized file: bigfile.pdf

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 414 == 413

1 failed, 41 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 53
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -314,7 +314,7 @@
         if file.content_length and file.content_length > MAX_FILE_SIZE:
             inc_suspicious("upload_oversize")
             app.logger.warning("Upload attempt with oversized file: %s", file.filename)
-            return jsonify({"error": "file too large"}), 413
+            return jsonify({"error": "file too large"}), 412
 
         # Validate file type and MIME type
         if file.mimetype != "application/pdf":
...F......................................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

>           assert resp.status_code == 413

E           assert 412 == 413

E            +  where 412 = <WrapperTestResponse streamed [412 PRECONDITION FAILED]>.status_code



..\test\test_api.py:196: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

WARNING  server:server.py:316 Upload attempt with oversized file: bigfile.pdf

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 412 == 413

1 failed, 41 passed, 23 warnings in 21.33s

operator: core/NumberReplacer, occurrence: 54
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -322,7 +322,7 @@
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
             )
-            return jsonify({"error": "only PDF files are allowed"}), 415
+            return jsonify({"error": "only PDF files are allowed"}), 416
         if not file.filename.lower().endswith(".pdf"):
             inc_suspicious("upload_bad_extension")
             app.logger.warning(
...F......................................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            assert resp.status_code == 413

    

        #Test with type error, txt file

        resp = client.post("/api/upload-document",

                           data={'file': (BytesIO(b"example"), "test.txt", "text/plain"),

                            'name': 'file'},

                            content_type='multipart/form-data')

>       assert resp.status_code == 415

E       assert 416 == 415

E        +  where 416 = <WrapperTestResponse streamed [416 REQUESTED RANGE NOT SATISFIABLE]>.status_code



..\test\test_api.py:203: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

WARNING  server:server.py:316 Upload attempt with oversized file: bigfile.pdf

WARNING  server:server.py:322 Upload attempt with invalid MIME type: text/plain

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 416 == 415

1 failed, 41 passed, 23 warnings in 21.12s

operator: core/NumberReplacer, occurrence: 55
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -322,7 +322,7 @@
             app.logger.warning(
                 "Upload attempt with invalid MIME type: %s", file.mimetype
             )
-            return jsonify({"error": "only PDF files are allowed"}), 415
+            return jsonify({"error": "only PDF files are allowed"}), 414
         if not file.filename.lower().endswith(".pdf"):
             inc_suspicious("upload_bad_extension")
             app.logger.warning(
...F......................................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

            assert resp.status_code == 201

            assert resp.is_json

            #check types

            assert isinstance(resp_data.get("id"), int) #was string! Specification is wrong.

            assert isinstance(resp_data.get("name"), str)

            assert isinstance(resp_data.get("creation"), str) and datetime.fromisoformat(resp_data.get("creation"))

            assert isinstance(resp_data.get("sha256"), str)

            assert isinstance(resp_data.get("size"), int)

            #check value

            assert resp_data.get("name") == parameters["name"]

    

        #Test with missing file

        resp = client.post("/api/upload-document")

        assert resp.status_code == 400

    

        #Test with too big file, 51 Mb

        content = b"%PDF-1.4\n" + b"0" * (50 * 1024 * 1024 + 1)  # 50MB + 1 byte

        stream = BytesIO(content)

        file_storage = FileStorage(stream=stream, filename="bigfile.pdf", content_type="application/pdf")

    

        #Need to patch the content length, not included in flask test server

        with patch.object(FileStorage, 'content_length', new_callable=PropertyMock) as mock_content_length:

            mock_content_length.return_value = len(content)

    

            data = {

                'file': (file_storage.stream, file_storage.filename, file_storage.content_type),

                'name': 'My Big File'

            }

            resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            assert resp.status_code == 413

    

        #Test with type error, txt file

        resp = client.post("/api/upload-document",

                           data={'file': (BytesIO(b"example"), "test.txt", "text/plain"),

                            'name': 'file'},

                            content_type='multipart/form-data')

>       assert resp.status_code == 415

E       assert 414 == 415

E        +  where 414 = <WrapperTestResponse streamed [414 REQUEST URI TOO LONG]>.status_code



..\test\test_api.py:203: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:303 Upload attempt missing 'file' field

WARNING  server:server.py:316 Upload attempt with oversized file: bigfile.pdf

WARNING  server:server.py:322 Upload attempt with invalid MIME type: text/plain

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 414 == 415

1 failed, 41 passed, 23 warnings in 21.05s

operator: core/NumberReplacer, occurrence: 56
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -328,7 +328,7 @@
             app.logger.warning(
                 "Upload attempt with invalid file extension: %s", file.filename
             )
-            return jsonify({"error": "only PDF files are allowed"}), 415
+            return jsonify({"error": "only PDF files are allowed"}), 416
 
         # Sanitize filename
         fname = secure_filename(file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/NumberReplacer, occurrence: 57
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -328,7 +328,7 @@
             app.logger.warning(
                 "Upload attempt with invalid file extension: %s", file.filename
             )
-            return jsonify({"error": "only PDF files are allowed"}), 415
+            return jsonify({"error": "only PDF files are allowed"}), 414
 
         # Sanitize filename
         fname = secure_filename(file.filename)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/NumberReplacer, occurrence: 58
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -336,7 +336,7 @@
             app.logger.warning(
                 "Upload attempt with invalid filename: %s", file.filename
             )
-            return jsonify({"error": "invalid filename"}), 400
+            return jsonify({"error": "invalid filename"}), 401
 
         user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 59
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -336,7 +336,7 @@
             app.logger.warning(
                 "Upload attempt with invalid filename: %s", file.filename
             )
-            return jsonify({"error": "invalid filename"}), 400
+            return jsonify({"error": "invalid filename"}), 399
 
         user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]
         user_dir.mkdir(parents=True, exist_ok=True)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.71s

operator: core/NumberReplacer, occurrence: 60
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -350,7 +350,7 @@
             stored_path = (user_dir / stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
-                return jsonify({"error": "invalid path"}), 400
+                return jsonify({"error": "invalid path"}), 401
 
             file.save(stored_path)
         except Exception as e:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 61
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -350,7 +350,7 @@
             stored_path = (user_dir / stored_name).resolve()
             if not str(stored_path).startswith(str(user_dir.resolve())):
                 app.logger.warning("Upload attempt with invalid path: %s", stored_path)
-                return jsonify({"error": "invalid path"}), 400
+                return jsonify({"error": "invalid path"}), 399
 
             file.save(stored_path)
         except Exception as e:
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T004748828776Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T004749695873Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.09s

operator: core/NumberReplacer, occurrence: 62
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -355,7 +355,7 @@
             file.save(stored_path)
         except Exception as e:
             app.logger.error("File save error: %s", e)
-            return jsonify({"error": "failed to save file"}), 500
+            return jsonify({"error": "failed to save file"}), 501
 
         sha_hex = _sha256_file(stored_path)
         size = stored_path.stat().st_size
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 63
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -355,7 +355,7 @@
             file.save(stored_path)
         except Exception as e:
             app.logger.error("File save error: %s", e)
-            return jsonify({"error": "failed to save file"}), 500
+            return jsonify({"error": "failed to save file"}), 499
 
         sha_hex = _sha256_file(stored_path)
         size = stored_path.stat().st_size
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/NumberReplacer, occurrence: 64
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -396,7 +396,7 @@
                 int(g.user["id"]),
             )
             inc_db_error("insert_document")
-            return jsonify({"error": "database error occurred"}), 503
+            return jsonify({"error": "database error occurred"}), 504
 
         observe_db_latency("insert_document", time.time() - start_db)
         resp_data = {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 65
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -396,7 +396,7 @@
                 int(g.user["id"]),
             )
             inc_db_error("insert_document")
-            return jsonify({"error": "database error occurred"}), 503
+            return jsonify({"error": "database error occurred"}), 502
 
         observe_db_latency("insert_document", time.time() - start_db)
         resp_data = {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 66
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -409,7 +409,7 @@
             "size": int(row.size),
         }
         inc_upload(int(row.size))
-        return jsonify(resp_data), 201
+        return jsonify(resp_data), 202
 
     # GET /api/list-documents
     @app.get("/api/list-documents")
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 202 == 201

E            +  where 202 = <WrapperTestResponse 155 bytes [202 ACCEPTED]>.status_code



..\test\test_api.py:167: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 202 == 201

E            +  where 202 = <WrapperTestResponse 158 bytes [202 ACCEPTED]>.status_code



..\test\test_api.py:404: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 202 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 202 == 201

2 failed, 40 passed, 23 warnings in 20.71s

operator: core/NumberReplacer, occurrence: 67
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -409,7 +409,7 @@
             "size": int(row.size),
         }
         inc_upload(int(row.size))
-        return jsonify(resp_data), 201
+        return jsonify(resp_data), 200
 
     # GET /api/list-documents
     @app.get("/api/list-documents")
...F......F...............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 200 == 201

E            +  where 200 = <WrapperTestResponse 155 bytes [200 OK]>.status_code



..\test\test_api.py:167: AssertionError

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 200 == 201

E            +  where 200 = <WrapperTestResponse 158 bytes [200 OK]>.status_code



..\test\test_api.py:404: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 200 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 200 == 201

2 failed, 40 passed, 23 warnings in 20.74s

operator: core/NumberReplacer, occurrence: 68
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -433,7 +433,7 @@
                 "Database error in list_documents for user=%s", g.user["id"]
             )
             inc_db_error("list_documents")
-            return jsonify({"error": "An error occurred while fetching documents"}), 503
+            return jsonify({"error": "An error occurred while fetching documents"}), 504
 
         docs = [
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/NumberReplacer, occurrence: 69
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -433,7 +433,7 @@
                 "Database error in list_documents for user=%s", g.user["id"]
             )
             inc_db_error("list_documents")
-            return jsonify({"error": "An error occurred while fetching documents"}), 503
+            return jsonify({"error": "An error occurred while fetching documents"}), 502
 
         docs = [
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 70
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -447,7 +447,7 @@
             }
             for r in rows
         ]
-        return jsonify({"documents": docs}), 200
+        return jsonify({"documents": docs}), 201
 
     # GET /api/list-versions
     @app.get("/api/list-versions")
....F.....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 171 bytes [201 CREATED]>.status_code



..\test\test_api.py:213: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_documents_route - assert 201 == 200

1 failed, 41 passed, 23 warnings in 21.06s

operator: core/NumberReplacer, occurrence: 71
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -447,7 +447,7 @@
             }
             for r in rows
         ]
-        return jsonify({"documents": docs}), 200
+        return jsonify({"documents": docs}), 199
 
     # GET /api/list-versions
     @app.get("/api/list-versions")
....F.....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

>       resp_data = resp.get_json()

                    ^^^^^^^^^^^^^^^



..\test\test_api.py:210: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\response.py:620: in get_json

    return self.json_module.loads(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\json\provider.py:187: in loads

    return json.loads(s, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py:346: in loads

    return _default_decoder.decode(s)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:337: in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <json.decoder.JSONDecoder object at 0x00000200418C12B0>, s = '', idx = 0



    def raw_decode(self, s, idx=0):

        """Decode a JSON document from ``s`` (a ``str`` beginning with

        a JSON document) and return a 2-tuple of the Python

        representation and the index in ``s`` where the document ended.

    

        This can be used to decode a JSON document from a string that may

        have extraneous data at the end.

    

        """

        try:

            obj, end = self.scan_once(s, idx)

        except StopIteration as err:

>           raise JSONDecodeError("Expecting value", s, err.value) from None

E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:355: JSONDecodeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_documents_route - json.decoder.JSONDeco...

1 failed, 41 passed, 23 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 72
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= 1 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 73
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -459,7 +459,7 @@
             document_id = request.args.get("id") or request.args.get("documentid")
             try:
                 document_id = int(document_id) if document_id else None
-                if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+                if document_id is None or document_id <= -1 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 74
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -461,7 +461,7 @@
                 document_id = int(document_id) if document_id else None
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
-                    return jsonify({"error": "document id required"}), 400
+                    return jsonify({"error": "document id required"}), 401
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        #extract data

        doc_list = resp_data.get("versions")

        assert isinstance(doc_list, list)

        #cycle through each element in the list

        for elem in doc_list:

            assert isinstance(elem.get("id"), str)

            assert isinstance(elem.get("documentid"), str)

            #check the version is from the correct document

            assert elem.get("documentid") == str(parameters["documentid"])

            assert isinstance(elem.get("link"), str)

            assert isinstance(elem.get("intended_for"), str)

            assert isinstance(elem.get("secret"), str)

            assert isinstance(elem.get("method"), str)

    

        #Test with no parameters

        resp = client.get("/api/list-versions")

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:254: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 75
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -461,7 +461,7 @@
                 document_id = int(document_id) if document_id else None
                 if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
                     app.logger.warning("Invalid document id in query")
-                    return jsonify({"error": "document id required"}), 400
+                    return jsonify({"error": "document id required"}), 399
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        #extract data

        doc_list = resp_data.get("versions")

        assert isinstance(doc_list, list)

        #cycle through each element in the list

        for elem in doc_list:

            assert isinstance(elem.get("id"), str)

            assert isinstance(elem.get("documentid"), str)

            #check the version is from the correct document

            assert elem.get("documentid") == str(parameters["documentid"])

            assert isinstance(elem.get("link"), str)

            assert isinstance(elem.get("intended_for"), str)

            assert isinstance(elem.get("secret"), str)

            assert isinstance(elem.get("method"), str)

    

        #Test with no parameters

        resp = client.get("/api/list-versions")

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:254: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 76
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -464,7 +464,7 @@
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
-                return jsonify({"error": "document id required"}), 400
+                return jsonify({"error": "document id required"}), 401
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 77
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -464,7 +464,7 @@
                     return jsonify({"error": "document id required"}), 400
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
-                return jsonify({"error": "document id required"}), 400
+                return jsonify({"error": "document id required"}), 399
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T113828706679Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T113829597571Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.38s

operator: core/NumberReplacer, occurrence: 78
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 1 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse 33 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 400 == 200

1 failed, 41 passed, 23 warnings in 21.09s

operator: core/NumberReplacer, occurrence: 79
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -466,7 +466,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= -1 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 80
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -467,7 +467,7 @@
                 return jsonify({"error": "document id required"}), 400
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         try:
             with get_engine().connect() as conn:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.66s

operator: core/NumberReplacer, occurrence: 81
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -467,7 +467,7 @@
                 return jsonify({"error": "document id required"}), 400
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         try:
             with get_engine().connect() as conn:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/NumberReplacer, occurrence: 82
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -486,7 +486,7 @@
                     app.logger.warning(
                         "Document not found or access denied for id=%s", document_id
                     )
-                    return jsonify({"error": "document not found"}), 404
+                    return jsonify({"error": "document not found"}), 405
 
                 # Then fetch versions with ownership validation
                 rows = conn.execute(
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        #extract data

        doc_list = resp_data.get("versions")

        assert isinstance(doc_list, list)

        #cycle through each element in the list

        for elem in doc_list:

            assert isinstance(elem.get("id"), str)

            assert isinstance(elem.get("documentid"), str)

            #check the version is from the correct document

            assert elem.get("documentid") == str(parameters["documentid"])

            assert isinstance(elem.get("link"), str)

            assert isinstance(elem.get("intended_for"), str)

            assert isinstance(elem.get("secret"), str)

            assert isinstance(elem.get("method"), str)

    

        #Test with no parameters

        resp = client.get("/api/list-versions")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/list-versions", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/list-versions", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 405 == 404

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:260: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:486 Document not found or access denied for id=4

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 405 == 404

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 83
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -486,7 +486,7 @@
                     app.logger.warning(
                         "Document not found or access denied for id=%s", document_id
                     )
-                    return jsonify({"error": "document not found"}), 404
+                    return jsonify({"error": "document not found"}), 403
 
                 # Then fetch versions with ownership validation
                 rows = conn.execute(
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 200

        assert resp.is_json

        #check types

        #extract data

        doc_list = resp_data.get("versions")

        assert isinstance(doc_list, list)

        #cycle through each element in the list

        for elem in doc_list:

            assert isinstance(elem.get("id"), str)

            assert isinstance(elem.get("documentid"), str)

            #check the version is from the correct document

            assert elem.get("documentid") == str(parameters["documentid"])

            assert isinstance(elem.get("link"), str)

            assert isinstance(elem.get("intended_for"), str)

            assert isinstance(elem.get("secret"), str)

            assert isinstance(elem.get("method"), str)

    

        #Test with no parameters

        resp = client.get("/api/list-versions")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/list-versions", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/list-versions", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 403 == 404

E        +  where 403 = <WrapperTestResponse streamed [403 FORBIDDEN]>.status_code



..\test\test_api.py:260: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:463 Invalid document id in query

WARNING  server:server.py:486 Document not found or access denied for id=4

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 403 == 404

1 failed, 41 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 84
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -505,7 +505,7 @@
                 f"Database error in list_versions: {document_id},{g.user['id']}"
             )
             inc_db_error("list_versions")
-            return jsonify({"error": "An error occurred while fetching versions"}), 503
+            return jsonify({"error": "An error occurred while fetching versions"}), 504
 
         versions = [
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 85
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -505,7 +505,7 @@
                 f"Database error in list_versions: {document_id},{g.user['id']}"
             )
             inc_db_error("list_versions")
-            return jsonify({"error": "An error occurred while fetching versions"}), 503
+            return jsonify({"error": "An error occurred while fetching versions"}), 502
 
         versions = [
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 86
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -518,7 +518,7 @@
             }
             for r in rows
         ]
-        return jsonify({"versions": versions}), 200
+        return jsonify({"versions": versions}), 201
 
     # GET /api/list-all-versions
     @app.get("/api/list-all-versions")
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 16 bytes [201 CREATED]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 201 == 200

1 failed, 41 passed, 23 warnings in 21.16s

operator: core/NumberReplacer, occurrence: 87
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -518,7 +518,7 @@
             }
             for r in rows
         ]
-        return jsonify({"versions": versions}), 200
+        return jsonify({"versions": versions}), 199
 
     # GET /api/list-all-versions
     @app.get("/api/list-all-versions")
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

>       resp_data = resp.get_json()

                    ^^^^^^^^^^^^^^^



..\test\test_api.py:232: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\response.py:620: in get_json

    return self.json_module.loads(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\json\provider.py:187: in loads

    return json.loads(s, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py:346: in loads

    return _default_decoder.decode(s)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:337: in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <json.decoder.JSONDecoder object at 0x000001F762DB12B0>, s = '', idx = 0



    def raw_decode(self, s, idx=0):

        """Decode a JSON document from ``s`` (a ``str`` beginning with

        a JSON document) and return a 2-tuple of the Python

        representation and the index in ``s`` where the document ended.

    

        This can be used to decode a JSON document from a string that may

        have extraneous data at the end.

    

        """

        try:

            obj, end = self.scan_once(s, idx)

        except StopIteration as err:

>           raise JSONDecodeError("Expecting value", s, err.value) from None

E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:355: JSONDecodeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - json.decoder.JSONDecod...

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/NumberReplacer, occurrence: 88
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -528,7 +528,7 @@
             # Validate user data from auth token
             if not g.user or not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
-                return jsonify({"error": "Invalid authentication"}), 401
+                return jsonify({"error": "Invalid authentication"}), 402
 
             with get_engine().connect() as conn:
                 rows = conn.execute(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/NumberReplacer, occurrence: 89
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -528,7 +528,7 @@
             # Validate user data from auth token
             if not g.user or not g.user.get("id"):
                 app.logger.error("Missing user info in auth token")
-                return jsonify({"error": "Invalid authentication"}), 401
+                return jsonify({"error": "Invalid authentication"}), 400
 
             with get_engine().connect() as conn:
                 rows = conn.execute(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 90
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -546,7 +546,7 @@
                 ).all()
         except ValueError:
             app.logger.error("Invalid user ID in auth token")
-            return jsonify({"error": "Authentication error"}), 401
+            return jsonify({"error": "Authentication error"}), 402
         except Exception:
             app.logger.error(
                 "Database error in list_all_versions for user=%s", g.user["id"]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 91
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -546,7 +546,7 @@
                 ).all()
         except ValueError:
             app.logger.error("Invalid user ID in auth token")
-            return jsonify({"error": "Authentication error"}), 401
+            return jsonify({"error": "Authentication error"}), 400
         except Exception:
             app.logger.error(
                 "Database error in list_all_versions for user=%s", g.user["id"]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 92
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -552,7 +552,7 @@
                 "Database error in list_all_versions for user=%s", g.user["id"]
             )
             inc_db_error("list_all_versions")
-            return jsonify({"error": "An error occurred while fetching versions"}), 503
+            return jsonify({"error": "An error occurred while fetching versions"}), 504
 
         versions = [
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.31s

operator: core/NumberReplacer, occurrence: 93
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -552,7 +552,7 @@
                 "Database error in list_all_versions for user=%s", g.user["id"]
             )
             inc_db_error("list_all_versions")
-            return jsonify({"error": "An error occurred while fetching versions"}), 503
+            return jsonify({"error": "An error occurred while fetching versions"}), 502
 
         versions = [
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 94
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -564,7 +564,7 @@
             }
             for r in rows
         ]
-        return jsonify({"versions": versions}), 200
+        return jsonify({"versions": versions}), 201
 
     # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
     @app.get("/api/get-document")
......F...................................                               [100%]

================================== FAILURES ===================================

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 16 bytes [201 CREATED]>.status_code



..\test\test_api.py:270: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 201 == 200

1 failed, 41 passed, 23 warnings in 21.10s

operator: core/NumberReplacer, occurrence: 95
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -564,7 +564,7 @@
             }
             for r in rows
         ]
-        return jsonify({"versions": versions}), 200
+        return jsonify({"versions": versions}), 199
 
     # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
     @app.get("/api/get-document")
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124105483587Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124106386928Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 96
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -578,7 +578,7 @@
                 document_id = int(document_id)
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
-                return jsonify({"error": "document id required"}), 400
+                return jsonify({"error": "document id required"}), 401
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:302: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 97
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -578,7 +578,7 @@
                 document_id = int(document_id)
             except (TypeError, ValueError):
                 app.logger.warning("Invalid document id in query")
-                return jsonify({"error": "document id required"}), 400
+                return jsonify({"error": "document id required"}), 399
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:302: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 21.31s

operator: core/NumberReplacer, occurrence: 98
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= 1 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 41 passed, 23 warnings in 21.15s

operator: core/NumberReplacer, occurrence: 99
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -580,7 +580,7 @@
                 app.logger.warning("Invalid document id in query")
                 return jsonify({"error": "document id required"}), 400
 
-        if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
+        if document_id is None or document_id <= -1 or document_id > MAX_DB_INT:
             return jsonify({"error": "document id required"}), 400
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 100
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -581,7 +581,7 @@
                 return jsonify({"error": "document id required"}), 400
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         try:
             with get_engine().connect() as conn:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.58s

operator: core/NumberReplacer, occurrence: 101
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -581,7 +581,7 @@
                 return jsonify({"error": "document id required"}), 400
 
         if document_id is None or document_id <= 0 or document_id > MAX_DB_INT:
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         try:
             with get_engine().connect() as conn:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.49s

operator: core/NumberReplacer, occurrence: 102
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -603,7 +603,7 @@
             inc_db_error("get_document")
             return jsonify(
                 {"error": "An error occurred while fetching the document"}
-            ), 503
+            ), 504
 
         # DonÔÇÖt leak whether a doc exists for another user
         if not row:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 103
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -603,7 +603,7 @@
             inc_db_error("get_document")
             return jsonify(
                 {"error": "An error occurred while fetching the document"}
-            ), 503
+            ), 502
 
         # DonÔÇÖt leak whether a doc exists for another user
         if not row:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 104
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -610,7 +610,7 @@
             app.logger.warning(
                 "Document not found or access denied for id=%s", document_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         storage_root = app.config["STORAGE_DIR"].resolve()
         file_path = Path(row.path)
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/get-document", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/get-document", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 405 == 404

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:308: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

WARNING  server:server.py:580 Invalid document id in query

WARNING  server:server.py:610 Document not found or access denied for id=4

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 405 == 404

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:460: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert 405 == 404

FAILED ..\test\test_api.py::test_delete_document_route - assert 405 == 404

2 failed, 40 passed, 23 warnings in 21.64s

operator: core/NumberReplacer, occurrence: 105
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -610,7 +610,7 @@
             app.logger.warning(
                 "Document not found or access denied for id=%s", document_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         storage_root = app.config["STORAGE_DIR"].resolve()
         file_path = Path(row.path)
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        #Test with no parameters

        resp = client.get("/api/get-document")

        assert resp.status_code == 400

        #Test with json parameters

        resp = client.get("/api/get-document", json = parameters)

        assert resp.status_code == 400

        #Test with wrong parameters (missing file)

        resp = client.get("/api/get-document", query_string = {'documentid': 4})

>       assert resp.status_code == 404

E       assert 403 == 404

E        +  where 403 = <WrapperTestResponse streamed [403 FORBIDDEN]>.status_code



..\test\test_api.py:308: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:580 Invalid document id in query

WARNING  server:server.py:580 Invalid document id in query

WARNING  server:server.py:610 Document not found or access denied for id=4

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

>       assert resp_deletion.status_code == 404

E       assert 403 == 404

E        +  where 403 = <WrapperTestResponse streamed [403 FORBIDDEN]>.status_code



..\test\test_api.py:460: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert 403 == 404

FAILED ..\test\test_api.py::test_delete_document_route - assert 403 == 404

2 failed, 40 passed, 23 warnings in 21.24s

operator: core/NumberReplacer, occurrence: 106
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -624,7 +624,7 @@
             app.logger.warning(
                 "Rejected document path for id %s: %s", document_id, row.path
             )
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 501
 
         if not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 107
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -624,7 +624,7 @@
             app.logger.warning(
                 "Rejected document path for id %s: %s", document_id, row.path
             )
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 499
 
         if not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.31s

operator: core/NumberReplacer, occurrence: 108
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -628,7 +628,7 @@
 
         if not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         # TOCTOU-safe open and validation
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 109
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -628,7 +628,7 @@
 
         if not resolved.exists():
             app.logger.error("File missing on disk for document id=%s", document_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         # TOCTOU-safe open and validation
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 110
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -635,7 +635,7 @@
             f = open(resolved, "rb")
         except OSError:
             app.logger.error("File missing on disk for document id=%s", document_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         try:
             # Quick PDF signature check
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 111
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -635,7 +635,7 @@
             f = open(resolved, "rb")
         except OSError:
             app.logger.error("File missing on disk for document id=%s", document_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         try:
             # Quick PDF signature check
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 112
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -639,7 +639,7 @@
 
         try:
             # Quick PDF signature check
-            head = f.read(5)
+            head = f.read( 6)
             if head != b"%PDF-":
                 f.close()
                 app.logger.warning(
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:645 Invalid PDF signature for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 41 passed, 23 warnings in 21.21s

operator: core/NumberReplacer, occurrence: 113
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -639,7 +639,7 @@
 
         try:
             # Quick PDF signature check
-            head = f.read(5)
+            head = f.read( 4)
             if head != b"%PDF-":
                 f.close()
                 app.logger.warning(
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:645 Invalid PDF signature for document id=1

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 41 passed, 23 warnings in 21.13s

operator: core/NumberReplacer, occurrence: 114
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -645,7 +645,7 @@
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
                 )
-                return jsonify({"error": "document not available"}), 415
+                return jsonify({"error": "document not available"}), 416
 
             f.seek(0)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 115
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -645,7 +645,7 @@
                 app.logger.warning(
                     "Invalid PDF signature for document id=%s", document_id
                 )
-                return jsonify({"error": "document not available"}), 415
+                return jsonify({"error": "document not available"}), 414
 
             f.seek(0)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 116
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -647,7 +647,7 @@
                 )
                 return jsonify({"error": "document not available"}), 415
 
-            f.seek(0)
+            f.seek( 1)
 
             # Prepare safe filename (preserve existing .pdf if present)
             name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/NumberReplacer, occurrence: 117
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -647,7 +647,7 @@
                 )
                 return jsonify({"error": "document not available"}), 415
 
-            f.seek(0)
+            f.seek( -1)
 
             # Prepare safe filename (preserve existing .pdf if present)
             name = (row.name or "document").strip().replace("\r", "").replace("\n", "")
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:687 Error serving file for document id=1: [Errno 22] Invalid argument

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 118
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -663,7 +663,7 @@
                 as_attachment=False,
                 download_name=name,
                 conditional=False,  # enables 304 if If-Modified-Since/Range handling
-                max_age=0,
+                max_age= 1,
                 last_modified=st.st_mtime,
             )
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 119
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -663,7 +663,7 @@
                 as_attachment=False,
                 download_name=name,
                 conditional=False,  # enables 304 if If-Modified-Since/Range handling
-                max_age=0,
+                max_age= -1,
                 last_modified=st.st_mtime,
             )
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.64s

operator: core/NumberReplacer, occurrence: 120
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -687,7 +687,7 @@
             app.logger.error(
                 "Error serving file for document id=%s: %s", document_id, e
             )
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 501
 
     # GET /api/get-version/<link>   returns the watermarked PDF (inline)
     @app.get("/api/get-version/<link>")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 121
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -687,7 +687,7 @@
             app.logger.error(
                 "Error serving file for document id=%s: %s", document_id, e
             )
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 499
 
     # GET /api/get-version/<link>   returns the watermarked PDF (inline)
     @app.get("/api/get-version/<link>")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 122
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -695,7 +695,7 @@
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
         if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
             app.logger.warning("Invalid version link format: %s", link)
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         try:
             with get_engine().connect() as conn:
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614ec054430c97cba703'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        # Test with malformed request

        resp = client.get("/api/get-version/123malformedlink")

>       assert resp.status_code == 404

E       assert 405 == 404

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:618: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:697 Invalid version link format: 123malformedlink

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert 405 == 404

1 failed, 41 passed, 23 warnings in 21.51s

operator: core/NumberReplacer, occurrence: 123
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -695,7 +695,7 @@
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
         if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
             app.logger.warning("Invalid version link format: %s", link)
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         try:
             with get_engine().connect() as conn:
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e5c87e7ddcd8110c9'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

        assert is_pdf

        assert is_inline

    

        # Test with malformed request

        resp = client.get("/api/get-version/123malformedlink")

>       assert resp.status_code == 404

E       assert 403 == 404

E        +  where 403 = <WrapperTestResponse streamed [403 FORBIDDEN]>.status_code



..\test\test_api.py:618: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:697 Invalid version link format: 123malformedlink

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert 403 == 404

1 failed, 41 passed, 23 warnings in 21.21s

operator: core/NumberReplacer, occurrence: 124
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -713,7 +713,7 @@
         except Exception as e:
             app.logger.error("Database error in get_version: %s", e)
             inc_db_error("get_version")
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 504
 
         if not row:
             app.logger.warning("Version not found for link: %s", link)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133655478535Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133656388646Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.50s

operator: core/NumberReplacer, occurrence: 125
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -713,7 +713,7 @@
         except Exception as e:
             app.logger.error("Database error in get_version: %s", e)
             inc_db_error("get_version")
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 502
 
         if not row:
             app.logger.warning("Version not found for link: %s", link)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 126
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -717,7 +717,7 @@
 
         if not row:
             app.logger.warning("Version not found for link: %s", link)
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         try:
             resolved = _safe_resolve_under_storage(row.path, app.config["STORAGE_DIR"])
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 127
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -717,7 +717,7 @@
 
         if not row:
             app.logger.warning("Version not found for link: %s", link)
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         try:
             resolved = _safe_resolve_under_storage(row.path, app.config["STORAGE_DIR"])
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/NumberReplacer, occurrence: 128
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -725,7 +725,7 @@
             app.logger.warning(
                 "Rejected version path for link %s: %s (%s)", link, row.path, exc
             )
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 501
 
         if not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/NumberReplacer, occurrence: 129
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -725,7 +725,7 @@
             app.logger.warning(
                 "Rejected version path for link %s: %s (%s)", link, row.path, exc
             )
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 499
 
         if not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.40s

operator: core/NumberReplacer, occurrence: 130
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -729,7 +729,7 @@
 
         if not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         try:
             with resolved.open("rb") as fh:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 131
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -729,7 +729,7 @@
 
         if not resolved.exists():
             app.logger.error("File missing on disk for version link=%s", link)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         try:
             with resolved.open("rb") as fh:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 132
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -733,7 +733,7 @@
 
         try:
             with resolved.open("rb") as fh:
-                header = fh.read(5)
+                header = fh.read( 6)
                 if header != b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e1e7da96d07f63285'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:738 Invalid PDF signature for version link=0000000000bc614e1e7da96d07f63285

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 133
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -733,7 +733,7 @@
 
         try:
             with resolved.open("rb") as fh:
-                header = fh.read(5)
+                header = fh.read( 4)
                 if header != b"%PDF-":
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e5ee917565f7bda44'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:738 Invalid PDF signature for version link=0000000000bc614e5ee917565f7bda44

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.13s

operator: core/NumberReplacer, occurrence: 134
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -738,7 +738,7 @@
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
-                    return jsonify({"error": "document not available"}), 415
+                    return jsonify({"error": "document not available"}), 416
                 fh.seek(0)
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 135
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -738,7 +738,7 @@
                     app.logger.warning(
                         "Invalid PDF signature for version link=%s", link
                     )
-                    return jsonify({"error": "document not available"}), 415
+                    return jsonify({"error": "document not available"}), 414
                 fh.seek(0)
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/NumberReplacer, occurrence: 136
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -739,7 +739,7 @@
                         "Invalid PDF signature for version link=%s", link
                     )
                     return jsonify({"error": "document not available"}), 415
-                fh.seek(0)
+                fh.seek( 1)
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 137
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -739,7 +739,7 @@
                         "Invalid PDF signature for version link=%s", link
                     )
                     return jsonify({"error": "document not available"}), 415
-                fh.seek(0)
+                fh.seek( -1)
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e3b3cc2d804ac731c'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:745 File missing on disk for version link=0000000000bc614e3b3cc2d804ac731c

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.08s

operator: core/NumberReplacer, occurrence: 138
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -743,7 +743,7 @@
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
         except Exception as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
             return jsonify({"error": "error serving file"}), 500
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 139
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -743,7 +743,7 @@
                 last_modified = os.fstat(fh.fileno()).st_mtime
         except OSError:
             app.logger.error("File missing on disk for version link=%s", link)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
         except Exception as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
             return jsonify({"error": "error serving file"}), 500
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.29s

operator: core/NumberReplacer, occurrence: 140
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -746,7 +746,7 @@
             return jsonify({"error": "file missing on disk"}), 410
         except Exception as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 501
 
         download_name = (
             row.link if row.link.lower().endswith(".pdf") else f"{row.link}.pdf"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/NumberReplacer, occurrence: 141
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -746,7 +746,7 @@
             return jsonify({"error": "file missing on disk"}), 410
         except Exception as e:
             app.logger.error("Error inspecting version file for %s: %s", link, e)
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 499
 
         download_name = (
             row.link if row.link.lower().endswith(".pdf") else f"{row.link}.pdf"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 142
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -760,7 +760,7 @@
                 as_attachment=False,
                 download_name=safe_download,
                 conditional=True,
-                max_age=0,
+                max_age= 1,
                 last_modified=last_modified,
             )
         except Exception as e:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.55s

operator: core/NumberReplacer, occurrence: 143
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -760,7 +760,7 @@
                 as_attachment=False,
                 download_name=safe_download,
                 conditional=True,
-                max_age=0,
+                max_age= -1,
                 last_modified=last_modified,
             )
         except Exception as e:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/NumberReplacer, occurrence: 144
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -765,7 +765,7 @@
             )
         except Exception as e:
             app.logger.error("Error serving version %s: %s", link, e)
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 501
 
         resp.headers["Cache-Control"] = "private, max-age=0, must-revalidate"
         resp.headers["Content-Type"] = "application/pdf"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 145
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -765,7 +765,7 @@
             )
         except Exception as e:
             app.logger.error("Error serving version %s: %s", link, e)
-            return jsonify({"error": "error serving file"}), 500
+            return jsonify({"error": "error serving file"}), 499
 
         resp.headers["Cache-Control"] = "private, max-age=0, must-revalidate"
         resp.headers["Content-Type"] = "application/pdf"
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 146
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -812,7 +812,7 @@
 
         if document_id is None:
             app.logger.warning("Document id required for deletion")
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         try:
             doc_id = int(document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 147
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -812,7 +812,7 @@
 
         if document_id is None:
             app.logger.warning("Document id required for deletion")
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         try:
             doc_id = int(document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/NumberReplacer, occurrence: 148
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -818,7 +818,7 @@
             doc_id = int(document_id)
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id for deletion: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         if doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 149
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -818,7 +818,7 @@
             doc_id = int(document_id)
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id for deletion: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         if doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 150
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= 1 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/NumberReplacer, occurrence: 151
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -820,7 +820,7 @@
             app.logger.warning("Invalid document id for deletion: %s", document_id)
             return jsonify({"error": "document id required"}), 400
 
-        if doc_id <= 0 or doc_id > MAX_DB_INT:
+        if doc_id <= -1 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
             return jsonify({"error": "document id required"}), 400
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

        assert resp_deletion.status_code == 404

    

        #Test missing id

        resp = client.delete("/api/delete-document")

>       assert resp.status_code == 400

E       assert 404 == 400

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:464: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=2

WARNING  server:server.py:850 Document not found or access denied for deletion id=0

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 400

1 failed, 41 passed, 23 warnings in 21.36s

operator: core/NumberReplacer, occurrence: 152
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -822,7 +822,7 @@
 
         if doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         owner_id = int(g.user["id"])
 
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

        resp_deletion = client.get("/api/get-document/2")

        assert resp_deletion.status_code == 404

    

        #Test missing id

        resp = client.delete("/api/delete-document")

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:464: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=2

WARNING  server:server.py:824 Non-positive document id for deletion: 0

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.10s

operator: core/NumberReplacer, occurrence: 153
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -822,7 +822,7 @@
 
         if doc_id <= 0 or doc_id > MAX_DB_INT:
             app.logger.warning("Non-positive document id for deletion: %s", doc_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         owner_id = int(g.user["id"])
 
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T003306338375Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T003307238653Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 21.05s

operator: core/NumberReplacer, occurrence: 154
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -843,7 +843,7 @@
         except Exception as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_select")
-            return jsonify({"error": "database error during delete"}), 503
+            return jsonify({"error": "database error during delete"}), 504
 
         if not row:
             # DonÔÇÖt reveal othersÔÇÖ docsÔÇöjust say not found
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/NumberReplacer, occurrence: 155
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -843,7 +843,7 @@
         except Exception as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_select")
-            return jsonify({"error": "database error during delete"}), 503
+            return jsonify({"error": "database error during delete"}), 502
 
         if not row:
             # DonÔÇÖt reveal othersÔÇÖ docsÔÇöjust say not found
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/NumberReplacer, occurrence: 156
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -850,7 +850,7 @@
             app.logger.warning(
                 "Document not found or access denied for deletion id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         # Resolve and delete file (best effort)
         storage_root = Path(app.config["STORAGE_DIR"])
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T151228944657Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T151229826554Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 405 == 200

8 failed, 34 passed, 23 warnings in 20.46s

operator: core/NumberReplacer, occurrence: 157
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -850,7 +850,7 @@
             app.logger.warning(
                 "Document not found or access denied for deletion id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         # Resolve and delete file (best effort)
         storage_root = Path(app.config["STORAGE_DIR"])
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.37s

operator: core/NumberReplacer, occurrence: 158
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -889,7 +889,7 @@
         except Exception as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_delete")
-            return jsonify({"error": "database error during delete"}), 503
+            return jsonify({"error": "database error during delete"}), 504
 
         return jsonify(
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 159
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -889,7 +889,7 @@
         except Exception as e:
             app.logger.error("DB delete error for doc id=%s: %s", doc_id, e)
             inc_db_error("delete_document_delete")
-            return jsonify({"error": "database error during delete"}), 503
+            return jsonify({"error": "database error during delete"}), 502
 
         return jsonify(
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 160
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -899,7 +899,7 @@
                 "file_missing": file_missing,
                 "note": delete_error,  # null/omitted if everything was fine
             }
-        ), 200
+        ), 201
 
     # POST /api/create-watermark or /api/create-watermark/<id>
     #  create watermarked pdf and returns metadata
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse streamed [201 CREATED]>.status_code



..\test\test_api.py:457: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 201 == 200

1 failed, 41 passed, 23 warnings in 21.21s

operator: core/NumberReplacer, occurrence: 161
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -899,7 +899,7 @@
                 "file_missing": file_missing,
                 "note": delete_error,  # null/omitted if everything was fine
             }
-        ), 200
+        ), 199
 
     # POST /api/create-watermark or /api/create-watermark/<id>
     #  create watermarked pdf and returns metadata
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 199 == 200

E        +  where 199 = <WrapperTestResponse streamed [199 UNKNOWN]>.status_code



..\test\test_api.py:457: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 199 == 200

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/NumberReplacer, occurrence: 162
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -918,7 +918,7 @@
             doc_id = document_id
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/NumberReplacer, occurrence: 163
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -918,7 +918,7 @@
             doc_id = document_id
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.70s

operator: core/NumberReplacer, occurrence: 164
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -932,7 +932,7 @@
         try:
             if doc_id is None:
                 app.logger.warning("Missing document id in request")
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 401
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:369: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 165
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -932,7 +932,7 @@
         try:
             if doc_id is None:
                 app.logger.warning("Missing document id in request")
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 399
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:369: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 166
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 1 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 42 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 20.75s

operator: core/NumberReplacer, occurrence: 167
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -934,7 +934,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= -1 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 168
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -935,7 +935,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 401
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/NumberReplacer, occurrence: 169
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -935,7 +935,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 399
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 170
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -938,7 +938,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
-            return jsonify({"error": "document_id (int) is required"}), 400
+            return jsonify({"error": "document_id (int) is required"}), 401
         if (
             not method
             or not intended_for
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/NumberReplacer, occurrence: 171
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -938,7 +938,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
-            return jsonify({"error": "document_id (int) is required"}), 400
+            return jsonify({"error": "document_id (int) is required"}), 399
         if (
             not method
             or not intended_for
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/NumberReplacer, occurrence: 172
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -948,7 +948,7 @@
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify(
                 {"error": "method, intended_for, secret, and key are required"}
-            ), 400
+            ), 401
 
         # lookup the document; enforce ownership
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:373: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.08s

operator: core/NumberReplacer, occurrence: 173
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -948,7 +948,7 @@
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify(
                 {"error": "method, intended_for, secret, and key are required"}
-            ), 400
+            ), 399
 
         # lookup the document; enforce ownership
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:373: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 21.13s

operator: core/NumberReplacer, occurrence: 174
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -966,7 +966,7 @@
                 ).first()
         except Exception as e:
             app.logger.error("Database error fetching document %s", e)
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 504
 
         if not row:
             app.logger.warning(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.51s

operator: core/NumberReplacer, occurrence: 175
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -966,7 +966,7 @@
                 ).first()
         except Exception as e:
             app.logger.error("Database error fetching document %s", e)
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 502
 
         if not row:
             app.logger.warning(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.22s

operator: core/NumberReplacer, occurrence: 176
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -972,7 +972,7 @@
             app.logger.warning(
                 "Document not found or access denied for watermarking id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105609036089Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 405 == 201

E        +  where 405 = <WrapperTestResponse 31 bytes [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105609929920Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 405 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.53s

operator: core/NumberReplacer, occurrence: 177
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -972,7 +972,7 @@
             app.logger.warning(
                 "Document not found or access denied for watermarking id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

>       assert resp.status_code == 404

E       assert 403 == 404

E        +  where 403 = <WrapperTestResponse streamed [403 FORBIDDEN]>.status_code



..\test\test_api.py:365: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 403 == 404

1 failed, 41 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 178
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -984,7 +984,7 @@
             file_path.relative_to(storage_root)
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 501
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 179
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -984,7 +984,7 @@
             file_path.relative_to(storage_root)
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 499
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 180
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -987,7 +987,7 @@
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         # check watermark applicability
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/NumberReplacer, occurrence: 181
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -987,7 +987,7 @@
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         # check watermark applicability
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/NumberReplacer, occurrence: 182
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1001,7 +1001,7 @@
                     method,
                     doc_id,
                 )
-                return jsonify({"error": "watermarking method not applicable"}), 400
+                return jsonify({"error": "watermarking method not applicable"}), 401
         except Exception as e:
             inc_watermark_failed(method, "applicability_exception")
             app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 183
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1001,7 +1001,7 @@
                     method,
                     doc_id,
                 )
-                return jsonify({"error": "watermarking method not applicable"}), 400
+                return jsonify({"error": "watermarking method not applicable"}), 399
         except Exception as e:
             inc_watermark_failed(method, "applicability_exception")
             app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/NumberReplacer, occurrence: 184
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1007,7 +1007,7 @@
             app.logger.error(
                 "Watermark applicability check failed for document %s: %s", doc_id, e
             )
-            return jsonify({"error": "watermark applicability check failed"}), 400
+            return jsonify({"error": "watermark applicability check failed"}), 401
 
         # apply watermark  bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:361: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 20.90s

operator: core/NumberReplacer, occurrence: 185
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1007,7 +1007,7 @@
             app.logger.error(
                 "Watermark applicability check failed for document %s: %s", doc_id, e
             )
-            return jsonify({"error": "watermark applicability check failed"}), 400
+            return jsonify({"error": "watermark applicability check failed"}), 399
 
         # apply watermark  bytes
         try:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:361: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/NumberReplacer, occurrence: 186
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 1:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 187
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1021,7 +1021,7 @@
                 position=position,
             )
             observe_watermark_duration(method, time.time() - _wm_start)
-            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == 0:
+            if not isinstance(wm_bytes, (bytes | bytearray)) or len(wm_bytes) == -1:
                 inc_watermark_failed(method, "empty_output")
                 app.logger.error(
                     "Watermarking produced no output for document %s using method %s",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 188
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1028,7 +1028,7 @@
                     doc_id,
                     method,
                 )
-                return jsonify({"error": "watermarking produced no output"}), 500
+                return jsonify({"error": "watermarking produced no output"}), 501
         except Exception as e:
             inc_watermark_failed(method, "exception")
             app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/NumberReplacer, occurrence: 189
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1028,7 +1028,7 @@
                     doc_id,
                     method,
                 )
-                return jsonify({"error": "watermarking produced no output"}), 500
+                return jsonify({"error": "watermarking produced no output"}), 499
         except Exception as e:
             inc_watermark_failed(method, "exception")
             app.logger.error(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/NumberReplacer, occurrence: 190
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1037,7 +1037,7 @@
                 method,
                 e,
             )
-            return jsonify({"error": "watermarking failed"}), 500
+            return jsonify({"error": "watermarking failed"}), 501
 
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105351406218Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105352270678Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.44s

operator: core/NumberReplacer, occurrence: 191
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1037,7 +1037,7 @@
                 method,
                 e,
             )
-            return jsonify({"error": "watermarking failed"}), 500
+            return jsonify({"error": "watermarking failed"}), 499
 
         # build destination file name: "<original_name>__<intended_to>.pdf"
         base_name = Path(row.name or file_path.name).stem
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/NumberReplacer, occurrence: 192
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1059,7 +1059,7 @@
                 doc_id,
                 e,
             )
-            return jsonify({"error": "failed to write watermarked file"}), 500
+            return jsonify({"error": "failed to write watermarked file"}), 501
 
         # link token = sha256(watermarked_file_name) - using stronger hash
         link_token = hashlib.sha256(candidate.encode("utf-8")).hexdigest()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 193
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1059,7 +1059,7 @@
                 doc_id,
                 e,
             )
-            return jsonify({"error": "failed to write watermarked file"}), 500
+            return jsonify({"error": "failed to write watermarked file"}), 499
 
         # link token = sha256(watermarked_file_name) - using stronger hash
         link_token = hashlib.sha256(candidate.encode("utf-8")).hexdigest()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/NumberReplacer, occurrence: 194
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1098,7 +1098,7 @@
                 "Integrity error during version insert for document %s: %s", doc_id, ie
             )
             inc_db_error("insert_version")
-            return jsonify({"error": "database error during version insert"}), 503
+            return jsonify({"error": "database error during version insert"}), 504
         except Exception:
             try:
                 dest_path.unlink(missing_ok=True)
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

>       assert resp.status_code == 503

E       assert 504 == 503

E        +  where 504 = <WrapperTestResponse streamed [504 GATEWAY TIMEOUT]>.status_code



..\test\test_api.py:357: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 504 == 503

1 failed, 41 passed, 23 warnings in 21.03s

operator: core/NumberReplacer, occurrence: 195
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1098,7 +1098,7 @@
                 "Integrity error during version insert for document %s: %s", doc_id, ie
             )
             inc_db_error("insert_version")
-            return jsonify({"error": "database error during version insert"}), 503
+            return jsonify({"error": "database error during version insert"}), 502
         except Exception:
             try:
                 dest_path.unlink(missing_ok=True)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T000051498528Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T000052383192Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 21.10s

operator: core/NumberReplacer, occurrence: 196
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1110,7 +1110,7 @@
                 "Database error during version insert for document %s", doc_id
             )
             inc_db_error("insert_version")
-            return jsonify({"error": "database error during version insert"}), 503
+            return jsonify({"error": "database error during version insert"}), 504
 
         inc_watermark_created(method)
         return jsonify(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/NumberReplacer, occurrence: 197
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1110,7 +1110,7 @@
                 "Database error during version insert for document %s", doc_id
             )
             inc_db_error("insert_version")
-            return jsonify({"error": "database error during version insert"}), 503
+            return jsonify({"error": "database error during version insert"}), 502
 
         inc_watermark_created(method)
         return jsonify(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/NumberReplacer, occurrence: 198
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1124,7 +1124,7 @@
                 "filename": candidate,
                 "size": len(wm_bytes),
             }
-        ), 201
+        ), 202
 
     # GET /api/get-watermarking-methods
     #  {"methods":[{"name":..., "description":...}, ...], "count":N}
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 202 == 201

E        +  where 202 = <WrapperTestResponse 229 bytes [202 ACCEPTED]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 202 == 201

1 failed, 41 passed, 23 warnings in 20.81s

operator: core/NumberReplacer, occurrence: 199
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1124,7 +1124,7 @@
                 "filename": candidate,
                 "size": len(wm_bytes),
             }
-        ), 201
+        ), 200
 
     # GET /api/get-watermarking-methods
     #  {"methods":[{"name":..., "description":...}, ...], "count":N}
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T170143988775Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T170144855582Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.45s

operator: core/NumberReplacer, occurrence: 200
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1137,7 +1137,7 @@
                 {"name": m, "description": WMUtils.get_method(m).get_usage()}
             )
 
-        return jsonify({"methods": methods, "count": len(methods)}), 200
+        return jsonify({"methods": methods, "count": len(methods)}), 201
 
     # POST /api/read-watermark
     @app.post("/api/read-watermark")
........F.................................                               [100%]

================================== FAILURES ===================================

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

        resp = client.get("/api/get-watermarking-methods")

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 201 == 200

E        +  where 201 = <WrapperTestResponse 532 bytes [201 CREATED]>.status_code



..\test\test_api.py:316: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - assert 201 ...

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/NumberReplacer, occurrence: 201
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1137,7 +1137,7 @@
                 {"name": m, "description": WMUtils.get_method(m).get_usage()}
             )
 
-        return jsonify({"methods": methods, "count": len(methods)}), 200
+        return jsonify({"methods": methods, "count": len(methods)}), 199
 
     # POST /api/read-watermark
     @app.post("/api/read-watermark")
.FFF.F.FFFFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T170333038413Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

        resp = client.get("/api/get-watermarking-methods")

>       data = resp.get_json()

               ^^^^^^^^^^^^^^^



..\test\test_api.py:313: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\wrappers\response.py:620: in get_json

    return self.json_module.loads(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\json\provider.py:187: in loads

    return json.loads(s, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py:346: in loads

    return _default_decoder.decode(s)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:337: in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <json.decoder.JSONDecoder object at 0x0000012124C712B0>, s = '', idx = 0



    def raw_decode(self, s, idx=0):

        """Decode a JSON document from ``s`` (a ``str`` beginning with

        a JSON document) and return a 2-tuple of the Python

        representation and the index in ``s`` where the document ended.

    

        This can be used to decode a JSON document from a string that may

        have extraneous data at the end.

    

        """

        try:

            obj, end = self.scan_once(s, idx)

        except StopIteration as err:

>           raise JSONDecodeError("Expecting value", s, err.value) from None

E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:355: JSONDecodeError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T170333965158Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - json.decode...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.49s

operator: core/NumberReplacer, occurrence: 202
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1155,7 +1155,7 @@
             doc_id = document_id
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 401
 
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 203
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1155,7 +1155,7 @@
             doc_id = document_id
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id in query: %s", document_id)
-            return jsonify({"error": "document id required"}), 400
+            return jsonify({"error": "document id required"}), 399
 
         payload = request.get_json(silent=True) or {}
         # allow a couple of aliases for convenience
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 204
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1167,7 +1167,7 @@
         try:
             if doc_id is None:
                 app.logger.warning("Missing document id in request")
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 401
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password"})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:437: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 205
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1167,7 +1167,7 @@
         try:
             if doc_id is None:
                 app.logger.warning("Missing document id in request")
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 399
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password"})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:437: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

WARNING  server:server.py:1169 Missing document id in request

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 23.17s

operator: core/NumberReplacer, occurrence: 206
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= 1 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/NumberReplacer, occurrence: 207
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1169,7 +1169,7 @@
                 app.logger.warning("Missing document id in request")
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
-            if doc_id <= 0 or doc_id > MAX_DB_INT:
+            if doc_id <= -1 or doc_id > MAX_DB_INT:
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 208
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1170,7 +1170,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 401
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/NumberReplacer, occurrence: 209
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1170,7 +1170,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
             doc_id = int(doc_id)
             if doc_id <= 0 or doc_id > MAX_DB_INT:
-                return jsonify({"error": "document_id (int) is required"}), 400
+                return jsonify({"error": "document_id (int) is required"}), 399
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
             return jsonify({"error": "document_id (int) is required"}), 400
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.50s

operator: core/NumberReplacer, occurrence: 210
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1173,7 +1173,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
-            return jsonify({"error": "document_id (int) is required"}), 400
+            return jsonify({"error": "document_id (int) is required"}), 401
         if not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 211
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1173,7 +1173,7 @@
                 return jsonify({"error": "document_id (int) is required"}), 400
         except (TypeError, ValueError):
             app.logger.warning("Invalid document id: %s", document_id)
-            return jsonify({"error": "document_id (int) is required"}), 400
+            return jsonify({"error": "document_id (int) is required"}), 399
         if not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
             return jsonify({"error": "method, and key are required"}), 400
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 212
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1176,7 +1176,7 @@
             return jsonify({"error": "document_id (int) is required"}), 400
         if not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
-            return jsonify({"error": "method, and key are required"}), 400
+            return jsonify({"error": "method, and key are required"}), 401
 
         # lookup the document; enforce ownership
         try:
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/read-watermark", json={"position": "metadata-only",

                                                        "key": "strong-password", "id": 2})

>       assert resp.status_code == 400

E       assert 401 == 400

E        +  where 401 = <WrapperTestResponse streamed [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:441: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

WARNING  server:server.py:1169 Missing document id in request

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 401 == 400

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 213
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1176,7 +1176,7 @@
             return jsonify({"error": "document_id (int) is required"}), 400
         if not method or not isinstance(method, str) or not isinstance(key, str):
             app.logger.warning("Missing required fields for watermarking: %s", payload)
-            return jsonify({"error": "method, and key are required"}), 400
+            return jsonify({"error": "method, and key are required"}), 399
 
         # lookup the document; enforce ownership
         try:
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/read-watermark", json={"position": "metadata-only",

                                                        "key": "strong-password", "id": 2})

>       assert resp.status_code == 400

E       assert 399 == 400

E        +  where 399 = <WrapperTestResponse streamed [399 UNKNOWN]>.status_code



..\test\test_api.py:441: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

WARNING  server:server.py:1169 Missing document id in request

WARNING  server:server.py:1178 Missing required fields for watermarking: {'id': 2, 'key': 'strong-password', 'position': 'metadata-only'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 399 == 400

1 failed, 41 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 214
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1196,7 +1196,7 @@
             app.logger.error(
                 "Database error fetching document %s for watermark read: %s", doc_id, e
             )
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 504
 
         if not row:
             app.logger.warning(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.64s

operator: core/NumberReplacer, occurrence: 215
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1196,7 +1196,7 @@
             app.logger.error(
                 "Database error fetching document %s for watermark read: %s", doc_id, e
             )
-            return jsonify({"error": "database error"}), 503
+            return jsonify({"error": "database error"}), 502
 
         if not row:
             app.logger.warning(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 216
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1202,7 +1202,7 @@
             app.logger.warning(
                 "Document not found or access denied for watermark read id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 405
 
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

>       assert resp.status_code == 404

E       assert 405 == 404

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:432: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 405 == 404

1 failed, 41 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 217
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1202,7 +1202,7 @@
             app.logger.warning(
                 "Document not found or access denied for watermark read id=%s", doc_id
             )
-            return jsonify({"error": "document not found"}), 404
+            return jsonify({"error": "document not found"}), 403
 
         # resolve path safely under STORAGE_DIR
         storage_root = Path(app.config["STORAGE_DIR"]).resolve()
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("secret"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Non existant id

        resp = client.post("/api/read-watermark", json={"method": "overlay-watermark",

                                                        "position": "metadata-only",

                                                        "key": "strong-password", "id": 8})

>       assert resp.status_code == 404

E       assert 403 == 404

E        +  where 403 = <WrapperTestResponse streamed [403 FORBIDDEN]>.status_code



..\test\test_api.py:432: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:1202 Document not found or access denied for watermark read id=8

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 403 == 404

1 failed, 41 passed, 23 warnings in 21.03s

operator: core/NumberReplacer, occurrence: 218
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1214,7 +1214,7 @@
             file_path.relative_to(storage_root)
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 501
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/NumberReplacer, occurrence: 219
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1214,7 +1214,7 @@
             file_path.relative_to(storage_root)
         except ValueError:
             app.logger.warning("Rejected document path for id %s: %s", doc_id, row.path)
-            return jsonify({"error": "document path invalid"}), 500
+            return jsonify({"error": "document path invalid"}), 499
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
             return jsonify({"error": "file missing on disk"}), 410
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 220
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1217,7 +1217,7 @@
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 411
 
         secret = None
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 221
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1217,7 +1217,7 @@
             return jsonify({"error": "document path invalid"}), 500
         if not file_path.exists():
             app.logger.error("File missing on disk for document id=%s", doc_id)
-            return jsonify({"error": "file missing on disk"}), 410
+            return jsonify({"error": "file missing on disk"}), 409
 
         secret = None
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 222
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1226,7 +1226,7 @@
             app.logger.error(
                 "Error when attempting to read watermark for document %s: %s", doc_id, e
             )
-            return jsonify({"error": "error when attempting to read watermark"}), 400
+            return jsonify({"error": "error when attempting to read watermark"}), 401
         inc_watermark_read(method)
         return jsonify(
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.62s

operator: core/NumberReplacer, occurrence: 223
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1226,7 +1226,7 @@
             app.logger.error(
                 "Error when attempting to read watermark for document %s: %s", doc_id, e
             )
-            return jsonify({"error": "error when attempting to read watermark"}), 400
+            return jsonify({"error": "error when attempting to read watermark"}), 399
         inc_watermark_read(method)
         return jsonify(
             {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.59s

operator: core/NumberReplacer, occurrence: 224
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1235,7 +1235,7 @@
                 "method": method,
                 "position": position,
             }
-        ), 201
+        ), 202
 
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 202 == 201

E        +  where 202 = <WrapperTestResponse 89 bytes [202 ACCEPTED]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 202 == 201

1 failed, 41 passed, 23 warnings in 24.58s

operator: core/NumberReplacer, occurrence: 225
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1235,7 +1235,7 @@
                 "method": method,
                 "position": position,
             }
-        ), 201
+        ), 200
 
     def _is_authorized_metrics_request() -> bool:
         token_required = os.environ.get("METRICS_TOKEN", "")
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 200 == 201

E        +  where 200 = <WrapperTestResponse 89 bytes [200 OK]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 200 == 201

1 failed, 41 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 226
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1251,7 +1251,7 @@
             app.logger.warning(
                 "Unauthorized metrics access attempt from %s", request.remote_addr
             )
-            return jsonify({"error": "not found"}), 404
+            return jsonify({"error": "not found"}), 405
         data = render_prometheus()
         return Response(data, mimetype="text/plain; version=0.0.4")
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/NumberReplacer, occurrence: 227
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1251,7 +1251,7 @@
             app.logger.warning(
                 "Unauthorized metrics access attempt from %s", request.remote_addr
             )
-            return jsonify({"error": "not found"}), 404
+            return jsonify({"error": "not found"}), 403
         data = render_prometheus()
         return Response(data, mimetype="text/plain; version=0.0.4")
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/NumberReplacer, occurrence: 228
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1262,7 +1262,7 @@
 app = create_app()
 
 if __name__ == "__main__":
-    port = int(os.environ.get("PORT", 5000))
+    port = int(os.environ.get("PORT", 5001))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
     app.run(host=host, port=port)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 229
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1262,7 +1262,7 @@
 app = create_app()
 
 if __name__ == "__main__":
-    port = int(os.environ.get("PORT", 5000))
+    port = int(os.environ.get("PORT", 4999))
     # Use localhost by default for security, allow override via environment variable
     host = os.environ.get("HOST", "127.0.0.1")
     app.run(host=host, port=port)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.66s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -96,7 +96,6 @@
         return jsonify({"error": msg}), code
 
     def require_auth(f):
-        @wraps(f)
         def wrapper(*args, **kwargs):
             if app.config['TESTING']:
                 g.user = {"id": 1, "login": "username", "email": "user@email.se"}

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:1261: in <module>

    app = create_app()

          ^^^^^^^^^^^^

server.py:414: in create_app

    @app.get("/api/list-documents")

     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\sansio\scaffold.py:362: in decorator

    self.add_url_rule(rule, endpoint, f, **options)

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\sansio\scaffold.py:47: in wrapper_func

    return f(self, *args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\sansio\app.py:657: in add_url_rule

    raise AssertionError(

E   AssertionError: View function mapping is overwriting an existing endpoint function: wrapper

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T15:06:53+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:06:53+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-17T15:06:54+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:06:54+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - AssertionError: View function mapping is overwrit...

!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

8 warnings, 1 error in 13.37s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -130,9 +130,6 @@
             for chunk in iter(lambda: f.read(1024 * 1024), b""):
                 h.update(chunk)
         return h.hexdigest()
-
-    # --- Request instrumentation hooks ---
-    @app.before_request  # type: ignore
     def _tatou_before():
         try:  # record start for latency
             request._tatou_start = time.time()  # type: ignore[attr-defined]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/RemoveDecorator, occurrence: 2
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -147,8 +147,6 @@
                 app.logger.warning("Request size capture failed: %s", exc)
         except Exception as exc:  # pragma: no cover - defensive
             app.logger.warning("before_request instrumentation failed: %s", exc)
-
-    @app.after_request  # type: ignore
     def _tatou_after(resp):
         try:
             start = getattr(request, "_tatou_start", None)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/RemoveDecorator, occurrence: 3
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -159,10 +159,6 @@
         except Exception as exc:  # pragma: no cover - defensive
             app.logger.warning("after_request instrumentation failed: %s", exc)
         return resp
-
-    # --- Routes ---
-
-    @app.route("/<path:filename>")
     def static_files(filename):
         return app.send_static_file(filename)
 
.FFFFFFF.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:232 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:276 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:389 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T112801783960Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:428 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:500 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:547 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:596 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:964 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:389 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T112802656552Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:840 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:232 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 23 warnings in 20.98s

operator: core/RemoveDecorator, occurrence: 4
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -165,8 +165,6 @@
     @app.route("/<path:filename>")
     def static_files(filename):
         return app.send_static_file(filename)
-
-    @app.route("/")
     def home():
         return app.send_static_file("index.html")
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/RemoveDecorator, occurrence: 5
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -169,8 +169,6 @@
     @app.route("/")
     def home():
         return app.send_static_file("index.html")
-
-    @app.get("/healthz")
     def healthz():
         try:
             with get_engine().connect() as conn:
F.........................................                               [100%]

================================== FAILURES ===================================

_____________________________ test_healthz_route ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_healthz_route(client):

        """Test the health check endpoint."""

        resp = client.get("/healthz")

    

>       assert resp.status_code == 200  # nosec B101

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:60: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_healthz_route - assert 404 == 200

1 failed, 41 passed, 23 warnings in 21.62s

operator: core/RemoveDecorator, occurrence: 6
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -192,9 +192,6 @@
         if not re.match(r"^[a-zA-Z0-9_-]{3,64}$", login):
             return False, "Invalid login format"
         return True, ""
-
-    # POST /api/create-user {email, login, password}
-    @app.post("/api/create-user")
     def create_user():
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip().lower()
.FFF.F.F.FFF.FF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 405 == 201

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:76: AssertionError

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:269 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:390 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T170516058600Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:483 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:607 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:969 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:390 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T170516885669Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:847 Document not found or access denied for deletion id=2

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:245 Failed to add source PDF to database: No users exist to own RMAP base document; create a user first

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 405 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

10 failed, 32 passed, 23 warnings in 20.17s

operator: core/RemoveDecorator, occurrence: 7
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -237,9 +237,6 @@
             return jsonify({"error": "database error"}), 503
 
         return jsonify({"id": row.id, "email": row.email, "login": row.login}), 201
-
-    # POST /api/login {login, password}
-    @app.post("/api/login")
     def login():
         payload = request.get_json(silent=True) or {}
         email = (payload.get("email") or "").strip()
..F.......................................                               [100%]

================================== FAILURES ===================================

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:129: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_login_route - assert 405 == 200

1 failed, 41 passed, 23 warnings in 21.44s

operator: core/RemoveDecorator, occurrence: 8
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -293,9 +293,6 @@
                 "expires_in": app.config["TOKEN_TTL_SECONDS"],
             }
         ), 200
-
-    # POST /api/upload-document  (multipart/form-data)
-    @app.post("/api/upload-document")
     @require_auth
     def upload_document():
         if "file" not in request.files:
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 405 == 201

E            +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:167: AssertionError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:483 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:607 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:969 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 405 == 201

E            +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:404: AssertionError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:847 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - assert 405 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 405 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.26s

operator: core/RemoveDecorator, occurrence: 9
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -296,7 +296,6 @@
 
     # POST /api/upload-document  (multipart/form-data)
     @app.post("/api/upload-document")
-    @require_auth
     def upload_document():
         if "file" not in request.files:
             inc_suspicious("upload_missing_file_field")
...F.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

>           resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:162: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:340: in upload_document

    user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

                                                     ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001AC1C24A750>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:485 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:609 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:971 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

>           upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:402: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1167: in post

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:340: in upload_document

    user_dir = app.config["STORAGE_DIR"] / "files" / g.user["login"]

                                                     ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001AC1C64EFC0>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:849 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_upload_document_route - AttributeError: user

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - AttributeError: user

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

6 failed, 36 passed, 23 warnings in 20.53s

operator: core/RemoveDecorator, occurrence: 10
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -410,9 +410,6 @@
         }
         inc_upload(int(row.size))
         return jsonify(resp_data), 201
-
-    # GET /api/list-documents
-    @app.get("/api/list-documents")
     @require_auth
     def list_documents():
         try:
....F.....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:213: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_documents_route - assert 404 == 200

1 failed, 41 passed, 23 warnings in 20.98s

operator: core/RemoveDecorator, occurrence: 11
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -413,7 +413,6 @@
 
     # GET /api/list-documents
     @app.get("/api/list-documents")
-    @require_auth
     def list_documents():
         try:
             with get_engine().connect() as conn:
....F.....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

>       resp = client.get("/api/list-documents")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:209: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:432: in list_documents

    "Database error in list_documents for user=%s", g.user["id"]

                                                    ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001DDE26664E0>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_documents_route - AttributeError: user

1 failed, 41 passed, 23 warnings in 21.06s

operator: core/RemoveDecorator, occurrence: 12
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -448,9 +448,6 @@
             for r in rows
         ]
         return jsonify({"documents": docs}), 200
-
-    # GET /api/list-versions
-    @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
     @require_auth
     def list_versions(document_id: int | None = None):
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/RemoveDecorator, occurrence: 13
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -451,7 +451,6 @@
 
     # GET /api/list-versions
     @app.get("/api/list-versions")
-    @app.get("/api/list-versions/<int:document_id>")
     @require_auth
     def list_versions(document_id: int | None = None):
         # Input validation
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/RemoveDecorator, occurrence: 14
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -452,7 +452,6 @@
     # GET /api/list-versions
     @app.get("/api/list-versions")
     @app.get("/api/list-versions/<int:document_id>")
-    @require_auth
     def list_versions(document_id: int | None = None):
         # Input validation
         if document_id is None:
.....F....................................                               [100%]

================================== FAILURES ===================================

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

>       resp = client.get("/api/list-versions", query_string = parameters)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:230: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:504: in list_versions

    f"Database error in list_versions: {document_id},{g.user['id']}"

                                                      ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x0000026FD820AA80>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_versions_route - AttributeError: user

1 failed, 41 passed, 23 warnings in 21.25s

operator: core/RemoveDecorator, occurrence: 15
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -519,9 +519,6 @@
             for r in rows
         ]
         return jsonify({"versions": versions}), 200
-
-    # GET /api/list-all-versions
-    @app.get("/api/list-all-versions")
     @require_auth
     def list_all_versions():
         try:
......F...................................                               [100%]

================================== FAILURES ===================================

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:270: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 404 == 200

1 failed, 41 passed, 23 warnings in 21.04s

operator: core/RemoveDecorator, occurrence: 16
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -522,7 +522,6 @@
 
     # GET /api/list-all-versions
     @app.get("/api/list-all-versions")
-    @require_auth
     def list_all_versions():
         try:
             # Validate user data from auth token
......F...................................                               [100%]

================================== FAILURES ===================================

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

>       resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:266: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:551: in list_all_versions

    "Database error in list_all_versions for user=%s", g.user["id"]

                                                       ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x00000225F1CE6270>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_list_all_versions_route - AttributeError: user

1 failed, 41 passed, 23 warnings in 21.09s

operator: core/RemoveDecorator, occurrence: 17
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -565,9 +565,6 @@
             for r in rows
         ]
         return jsonify({"versions": versions}), 200
-
-    # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
-    @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
     @require_auth
     def get_document(document_id: int | None = None):
.......F..................................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - assert False

1 failed, 41 passed, 23 warnings in 20.85s

operator: core/RemoveDecorator, occurrence: 18
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -568,7 +568,6 @@
 
     # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
     @app.get("/api/get-document")
-    @app.get("/api/get-document/<int:document_id>")
     @require_auth
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/RemoveDecorator, occurrence: 19
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -569,7 +569,6 @@
     # GET /api/get-document or /api/get-document/<id>   returns the PDF (inline)
     @app.get("/api/get-document")
     @app.get("/api/get-document/<int:document_id>")
-    @require_auth
     def get_document(document_id: int | None = None):
         # Support both path param and ?id=/ ?documentid=
         if document_id is None:
.......F...F..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

>       resp = client.get("/api/get-document", query_string=parameters)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:288: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:600: in get_document

    f"Database error in get_document: {document_id},{g.user['id']}"

                                                     ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001CC19F66900>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

        assert resp.status_code == 200

        #Test file is deleted

>       resp_deletion = client.get("/api/get-document/2")

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:459: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:600: in get_document

    f"Database error in get_document: {document_id},{g.user['id']}"

                                                     ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000001CC1A1ABB00>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_document_route - AttributeError: user

FAILED ..\test\test_api.py::test_delete_document_route - AttributeError: user

2 failed, 40 passed, 23 warnings in 21.45s

operator: core/RemoveDecorator, occurrence: 20
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -688,9 +688,6 @@
                 "Error serving file for document id=%s: %s", document_id, e
             )
             return jsonify({"error": "error serving file"}), 500
-
-    # GET /api/get-version/<link>   returns the watermarked PDF (inline)
-    @app.get("/api/get-version/<link>")
     def get_version(link: str):
         # Accept both 32-char (RMAP session secrets) and 64-char (SHA-256 style) tokens
         if not re.fullmatch(r"[0-9a-f]{32}|[0-9a-f]{64}", link):
..............F...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>

shared_link = {'version_link': '0000000000bc614e7126f22764368e5b'}



    def test_get_version_route(client, shared_link):

        route = "/api/get-version/" + shared_link.get("version_link").strip()

        resp = client.get(route)

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:613: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_version_route - assert False

1 failed, 41 passed, 23 warnings in 21.25s

operator: core/RemoveDecorator, occurrence: 21
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -796,9 +796,6 @@
                     f"path {fp} escapes storage root {storage_root}"
                 ) from None
         return fp
-
-    # DELETE /api/delete-document  (and variants) POST supported for convenience
-    @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
     def delete_document(document_id: int | None = None):
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:457: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - assert 405 == 200

1 failed, 41 passed, 23 warnings in 20.99s

operator: core/RemoveDecorator, occurrence: 22
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -799,7 +799,6 @@
 
     # DELETE /api/delete-document  (and variants) POST supported for convenience
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
-    @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
     @require_auth
     def delete_document(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/RemoveDecorator, occurrence: 23
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -800,7 +800,6 @@
     # DELETE /api/delete-document  (and variants) POST supported for convenience
     @app.route("/api/delete-document", methods=["DELETE", "POST"])
     @app.route("/api/delete-document/<document_id>", methods=["DELETE"])
-    @require_auth
     def delete_document(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if document_id in (None, ""):
...........F..............................                               [100%]

================================== FAILURES ===================================

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

>       resp = client.delete("/api/delete-document", json=document_id)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:454: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1177: in delete

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

server.py:826: in delete_document

    owner_id = int(g.user["id"])

                   ^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <flask.ctx._AppCtxGlobals object at 0x000002999FF907A0>, name = 'user'



    def __getattr__(self, name: str) -> t.Any:

        try:

            return self.__dict__[name]

        except KeyError:

>           raise AttributeError(name) from None

E           AttributeError: user



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\ctx.py:56: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_delete_document_route - AttributeError: user

1 failed, 41 passed, 23 warnings in 21.32s

operator: core/RemoveDecorator, occurrence: 24
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -900,10 +900,6 @@
                 "note": delete_error,  # null/omitted if everything was fine
             }
         ), 200
-
-    # POST /api/create-watermark or /api/create-watermark/<id>
-    #  create watermarked pdf and returns metadata
-    @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
     def create_watermark(document_id: int | None = None):
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 405 == 201

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:337: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 405 == 201

1 failed, 41 passed, 23 warnings in 20.76s

operator: core/RemoveDecorator, occurrence: 25
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -904,7 +904,6 @@
     # POST /api/create-watermark or /api/create-watermark/<id>
     #  create watermarked pdf and returns metadata
     @app.post("/api/create-watermark")
-    @app.post("/api/create-watermark/<int:document_id>")
     @require_auth
     def create_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/RemoveDecorator, occurrence: 26
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -905,7 +905,6 @@
     #  create watermarked pdf and returns metadata
     @app.post("/api/create-watermark")
     @app.post("/api/create-watermark/<int:document_id>")
-    @require_auth
     def create_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on GET
         if not document_id:
.........F................................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:967 Database error fetching document user

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/RemoveDecorator, occurrence: 27
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1125,10 +1125,6 @@
                 "size": len(wm_bytes),
             }
         ), 201
-
-    # GET /api/get-watermarking-methods
-    #  {"methods":[{"name":..., "description":...}, ...], "count":N}
-    @app.get("/api/get-watermarking-methods")
     def get_watermarking_methods():
         methods = []
 
........F.................................                               [100%]

================================== FAILURES ===================================

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

        resp = client.get("/api/get-watermarking-methods")

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:316: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - assert 404 ...

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/RemoveDecorator, occurrence: 28
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1138,9 +1138,6 @@
             )
 
         return jsonify({"methods": methods, "count": len(methods)}), 200
-
-    # POST /api/read-watermark
-    @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
     def read_watermark(document_id: int | None = None):
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 405 == 201

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:415: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 405 == 201

1 failed, 41 passed, 23 warnings in 20.79s

operator: core/RemoveDecorator, occurrence: 29
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1141,7 +1141,6 @@
 
     # POST /api/read-watermark
     @app.post("/api/read-watermark")
-    @app.post("/api/read-watermark/<int:document_id>")
     @require_auth
     def read_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/RemoveDecorator, occurrence: 30
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1142,7 +1142,6 @@
     # POST /api/read-watermark
     @app.post("/api/read-watermark")
     @app.post("/api/read-watermark/<int:document_id>")
-    @require_auth
     def read_watermark(document_id: int | None = None):
         # accept id from path, query (?id= / ?documentid=), or JSON body on POST
         if not document_id:
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1195 Database error fetching document 2 for watermark read: user

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

1 failed, 41 passed, 23 warnings in 20.94s

operator: core/RemoveDecorator, occurrence: 31
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1243,8 +1243,6 @@
         if provided != token_required:
             return False
         return True
-
-    @app.get("/metrics")
     def metrics():
         if not _is_authorized_metrics_request():
             # Obscure existence a bit ÔÇô return 404 instead of 403 to casual scans
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -127,7 +127,7 @@
     def _sha256_file(path: Path) -> str:
         h = hashlib.sha256()
         with path.open("rb") as f:
-            for chunk in iter(lambda: f.read(1024 * 1024), b""):
+            for chunk in []:
                 h.update(chunk)
         return h.hexdigest()
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- aserver.py
+++ bserver.py
@@ -1132,7 +1132,7 @@
     def get_watermarking_methods():
         methods = []
 
-        for m in WMUtils.METHODS:
+        for m in []:
             methods.append(
                 {"name": m, "description": WMUtils.get_method(m).get_usage()}
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str + WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.26s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str + WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str + None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str + None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.47s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str + WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str + None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str + WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str - WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str - WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str - None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str - None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str - WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125014434123Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T125015276487Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.55s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str - None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str - WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105937734865Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T105938580397Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.59s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str * WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str * WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str * None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str * None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str * WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str * None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.45s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str * WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str / WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str / WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str / None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str / None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str / WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str / None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str / WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T205717372640Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T205718378235Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 22.84s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str // WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.63s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str // WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str // None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str // None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str // WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str // None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str // WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str % WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str % WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.62s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str % None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str % None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str % WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str % None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.31s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str % WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str ** WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str ** WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str ** None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.71s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str ** None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str ** WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str ** None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.96s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str ** WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str >> WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str >> WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str >> None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str >> None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str >> WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str >> None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str >> WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str << WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str << WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str << None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str << None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.24s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str << WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.61s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str << None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str << WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T151018866502Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T151019754978Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.65s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str & WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str & WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.30s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str & None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str & None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str & WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str & None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str & WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -65,7 +65,7 @@
     METHODS[method.name] = method
 
 
-def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:
+def get_method(method: str ^ WatermarkingMethod) -> WatermarkingMethod:
     """Resolve a method from a string name or pass-through an instance.
 
     Raises
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T220837914653Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T220838760058Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.45s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -89,7 +89,7 @@
 
 
 def apply_watermark(
-    method: str | WatermarkingMethod,
+    method: str ^ WatermarkingMethod,
     pdf: PdfSource,
     secret: str,
     key: str,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -93,7 +93,7 @@
     pdf: PdfSource,
     secret: str,
     key: str,
-    intended_for: str | None = None,
+    intended_for: str ^ None = None,
     position: str | None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -94,7 +94,7 @@
     secret: str,
     key: str,
     intended_for: str | None = None,
-    position: str | None = None,
+    position: str ^ None = None,
 ) -> bytes:
     """Apply a watermark using the specified method and return new PDF bytes."""
     m = get_method(method)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -104,7 +104,7 @@
 
 
 def is_watermarking_applicable(
-    method: str | WatermarkingMethod,
+    method: str ^ WatermarkingMethod,
     pdf: PdfSource,
     position: str | None = None,
 ) -> bool:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -106,7 +106,7 @@
 def is_watermarking_applicable(
     method: str | WatermarkingMethod,
     pdf: PdfSource,
-    position: str | None = None,
+    position: str ^ None = None,
 ) -> bool:
     """Check if watermarking is applicable using the specified method."""
     m = get_method(method)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T103712357982Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T103713231743Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.51s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -113,7 +113,7 @@
     return m.is_watermark_applicable(pdf=pdf, position=position)
 
 
-def read_watermark(method: str | WatermarkingMethod, pdf: PdfSource, key: str) -> str:
+def read_watermark(method: str ^ WatermarkingMethod, pdf: PdfSource, key: str) -> str:
     """Recover a secret from ``pdf`` using the specified method."""
     m = get_method(method)
     return m.read_secret(pdf=pdf, key=key)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") != "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") < "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") <= "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") > "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") >= "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/ReplaceComparisonOperator_Eq_Is, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") is "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



watermarking_utils.py:232

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\watermarking_utils.py:232: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?

    page_nodes = [c for c in children if c.get("type") is "Page"]



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 20.72s

operator: core/ReplaceComparisonOperator_Eq_IsNot, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -229,7 +229,7 @@
         children.append(node)
 
     # Also derive simple page nodes by searching for '/Type /Page'
-    page_nodes = [c for c in children if c.get("type") == "Page"]
+    page_nodes = [c for c in children if c.get("type") is not "Page"]
     for i, c in enumerate(page_nodes):
         # Provide deterministic page IDs independent from object numbers
         c_page = {
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



watermarking_utils.py:232

  C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\watermarking_utils.py:232: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?

    page_nodes = [c for c in children if c.get("type") is not "Page"]



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 24 warnings in 20.81s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -73,7 +73,7 @@
     KeyError
         If ``method`` is a string not present in :data:`METHODS`.
     """
-    if isinstance(method, WatermarkingMethod):
+    if not isinstance(method, WatermarkingMethod):
         return method
     try:
         return METHODS[method]
........FFF..FF..........FFF.FFFF.........                               [100%]

================================== FAILURES ===================================

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

>       resp = client.get("/api/get-watermarking-methods")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:312: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.get("/api/get-watermarking-methods")

    def get_watermarking_methods():

        methods = []

    

        for m in WMUtils.METHODS:

            methods.append(

>               {"name": m, "description": WMUtils.get_method(m).get_usage()}

                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

            )

E           AttributeError: 'str' object has no attribute 'get_usage'



server.py:1137: AttributeError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 49 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: 'str' object has no attribute 'is_watermark_applicable'

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: 'str' object has no attribute 'read_secret'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 500 == 200

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:585: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:rmap_handler.py:352 Failed to create watermarked PDF for session 0000000000bc614e1d8d9d7bc82eed30: 'str' object has no attribute 'is_watermark_applicable'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

______________ TestWatermarkingUtils.test_get_method_with_string ______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001EC8EAC0BF0>



    def test_get_method_with_string(self):

        """Test get_method with string method names."""

        # Test valid method names

        for method_name in WMUtils.METHODS.keys():

            method = WMUtils.get_method(method_name)

>           assert isinstance(method, WatermarkingMethod)

E           AssertionError: assert False

E            +  where False = isinstance('robust-xmp', WatermarkingMethod)



..\test\test_watermarking_utilities.py:61: AssertionError

_____________ TestWatermarkingUtils.test_get_method_with_instance _____________



method = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if not isinstance(method, WatermarkingMethod):

            return method

        try:

>           return METHODS[method]

                   ^^^^^^^^^^^^^^^

E           KeyError: <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>



watermarking_utils.py:79: KeyError



The above exception was the direct cause of the following exception:



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001EC8EAC0D70>



    def test_get_method_with_instance(self):

        """Test get_method with WatermarkingMethod instance (passthrough)."""

        original_method = list(WMUtils.METHODS.values())[0]

>       returned_method = WMUtils.get_method(original_method)

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:67: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



method = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if not isinstance(method, WatermarkingMethod):

            return method

        try:

            return METHODS[method]

        except KeyError as exc:

>           raise KeyError(

                f"Unknown watermarking method: {method!r}. Known: {sorted(METHODS)}"

            ) from exc

E           KeyError: "Unknown watermarking method: <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"



watermarking_utils.py:81: KeyError

_____________ TestWatermarkingUtils.test_get_method_invalid_name ______________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001EC8EAC0EF0>



    def test_get_method_invalid_name(self):

        """Test get_method raises KeyError for invalid method names."""

>       with pytest.raises(KeyError) as exc_info:

E       Failed: DID NOT RAISE <class 'KeyError'>



..\test\test_watermarking_utilities.py:72: Failed

___ TestWatermarkingUtils.test_is_watermarking_applicable_with_method_name ____



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001EC8EAC1220>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp_h5vyz2e.pdf')



    def test_is_watermarking_applicable_with_method_name(self, sample_pdf_path):

        """Test is_watermarking_applicable with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

>       result = WMUtils.is_watermarking_applicable(method_name, sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:104: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



method = 'robust-xmp'

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp_h5vyz2e.pdf')

position = None



    def is_watermarking_applicable(

        method: str | WatermarkingMethod,

        pdf: PdfSource,

        position: str | None = None,

    ) -> bool:

        """Check if watermarking is applicable using the specified method."""

        m = get_method(method)

>       return m.is_watermark_applicable(pdf=pdf, position=position)

               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'str' object has no attribute 'is_watermark_applicable'



watermarking_utils.py:113: AttributeError

_ TestWatermarkingUtils.test_is_watermarking_applicable_with_method_instance __



method = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if not isinstance(method, WatermarkingMethod):

            return method

        try:

>           return METHODS[method]

                   ^^^^^^^^^^^^^^^

E           KeyError: <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>



watermarking_utils.py:79: KeyError



The above exception was the direct cause of the following exception:



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001EC8EAC13D0>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmprr334ft1.pdf')



    def test_is_watermarking_applicable_with_method_instance(self, sample_pdf_path):

        """Test is_watermarking_applicable with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

>       result = WMUtils.is_watermarking_applicable(method, sample_pdf_path)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:113: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:112: in is_watermarking_applicable

    m = get_method(method)

        ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



method = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if not isinstance(method, WatermarkingMethod):

            return method

        try:

            return METHODS[method]

        except KeyError as exc:

>           raise KeyError(

                f"Unknown watermarking method: {method!r}. Known: {sorted(METHODS)}"

            ) from exc

E           KeyError: "Unknown watermarking method: <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"



watermarking_utils.py:81: KeyError

_________ TestWatermarkingUtils.test_apply_watermark_with_method_name _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001EC8EAC1580>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpqgkjw8vu.pdf')



    def test_apply_watermark_with_method_name(self, sample_pdf_path):

        """Test apply_watermark with string method name."""

        method_name = list(WMUtils.METHODS.keys())[0]

    

        # Only test if method is applicable

>       if WMUtils.is_watermarking_applicable(method_name, sample_pdf_path):

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:123: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



method = 'robust-xmp'

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmpqgkjw8vu.pdf')

position = None



    def is_watermarking_applicable(

        method: str | WatermarkingMethod,

        pdf: PdfSource,

        position: str | None = None,

    ) -> bool:

        """Check if watermarking is applicable using the specified method."""

        m = get_method(method)

>       return m.is_watermark_applicable(pdf=pdf, position=position)

               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'str' object has no attribute 'is_watermark_applicable'



watermarking_utils.py:113: AttributeError

_______ TestWatermarkingUtils.test_apply_watermark_with_method_instance _______



method = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if not isinstance(method, WatermarkingMethod):

            return method

        try:

>           return METHODS[method]

                   ^^^^^^^^^^^^^^^

E           KeyError: <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>



watermarking_utils.py:79: KeyError



The above exception was the direct cause of the following exception:



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001EC8EAC1760>

sample_pdf_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/tmp3xb_49iz.pdf')



    def test_apply_watermark_with_method_instance(self, sample_pdf_path):

        """Test apply_watermark with method instance."""

        method = list(WMUtils.METHODS.values())[0]

    

        # Only test if method is applicable

>       if WMUtils.is_watermarking_applicable(method, sample_pdf_path):

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:139: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

watermarking_utils.py:112: in is_watermarking_applicable

    m = get_method(method)

        ^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



method = <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if not isinstance(method, WatermarkingMethod):

            return method

        try:

            return METHODS[method]

        except KeyError as exc:

>           raise KeyError(

                f"Unknown watermarking method: {method!r}. Known: {sorted(METHODS)}"

            ) from exc

E           KeyError: "Unknown watermarking method: <robust_xmp_watermark.RobustXmpWatermark object at 0x000001EC8BD7F380>. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"



watermarking_utils.py:81: KeyError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - AttributeEr...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_api.py::test_rmap_get_link - assert 500 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_get_method_with_string

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_get_method_with_instance

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_get_method_invalid_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_is_watermarking_applicable_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_is_watermarking_applicable_with_method_instance

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_name

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_apply_watermark_with_method_instance

12 failed, 30 passed, 23 warnings in 21.02s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -188,7 +188,7 @@
                 s = doc.xref_object(xref, compressed=False) or ""
             except Exception:
                 s = ""
-            s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
+            s_bytes = s.encode("latin-1", "replace") if not isinstance(s, str) else b""
             # Type detection
             m = _TYPE_RE.search(s_bytes)
             pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144312527264Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144313415208Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.51s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -191,7 +191,7 @@
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
             # Type detection
             m = _TYPE_RE.search(s_bytes)
-            pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"
+            pdf_type = m.group(1).decode("ascii", "replace") if not m else "Object"
             node = {
                 "id": f"obj:{xref:06d}",
                 "type": pdf_type,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.34s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -197,7 +197,7 @@
                 "type": pdf_type,
                 "xref": xref,
                 "is_stream": bool(doc.xref_is_stream(xref)),
-                "content_sha1": _sha1(s_bytes) if s_bytes else None,
+                "content_sha1": _sha1(s_bytes) if not s_bytes else None,
             }
             root["children"].append(node)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -214,7 +214,7 @@
         gen_num = int(m.group(2))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
-        end = end_match.start() if end_match else start
+        end = end_match.start() if not end_match else start
         slice_bytes = data[start:end]
         # Guess type
         t = _TYPE_RE.search(slice_bytes)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -218,7 +218,7 @@
         slice_bytes = data[start:end]
         # Guess type
         t = _TYPE_RE.search(slice_bytes)
-        pdf_type = t.group(1).decode("ascii", "replace") if t else "Object"
+        pdf_type = t.group(1).decode("ascii", "replace") if not t else "Object"
         node = {
             "id": f"obj:{obj_num:06d}:{gen_num:05d}",
             "type": pdf_type,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -130,7 +130,7 @@
 
 
 def _sha1(b: bytes) -> str:
-    return hashlib.sha1(b, usedforsecurity=False).hexdigest()
+    return hashlib.sha1(b, usedforsecurity=True).hexdigest()
 
 
 def explore_pdf(pdf: PdfSource) -> dict[str, Any]:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T235829047636Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T235829917393Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 21.27s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -185,7 +185,7 @@
         xref_len = doc.xref_length()
         for xref in range(1, xref_len):
             try:
-                s = doc.xref_object(xref, compressed=False) or ""
+                s = doc.xref_object(xref, compressed=True) or ""
             except Exception:
                 s = ""
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -185,7 +185,7 @@
         xref_len = doc.xref_length()
         for xref in range(1, xref_len):
             try:
-                s = doc.xref_object(xref, compressed=False) or ""
+                s = doc.xref_object(xref, compressed=False) and ""
             except Exception:
                 s = ""
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -77,7 +77,7 @@
         return method
     try:
         return METHODS[method]
-    except KeyError as exc:
+    except CosmicRayTestingException as exc:
         raise KeyError(
             f"Unknown watermarking method: {method!r}. Known: {sorted(METHODS)}"
         ) from exc
...........................F..............                               [100%]

================================== FAILURES ===================================

_____________ TestWatermarkingUtils.test_get_method_invalid_name ______________



method = 'nonexistent-method'



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if isinstance(method, WatermarkingMethod):

            return method

        try:

>           return METHODS[method]

                   ^^^^^^^^^^^^^^^

E           KeyError: 'nonexistent-method'



watermarking_utils.py:79: KeyError



During handling of the above exception, another exception occurred:



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000020386E10F50>



    def test_get_method_invalid_name(self):

        """Test get_method raises KeyError for invalid method names."""

        with pytest.raises(KeyError) as exc_info:

>           WMUtils.get_method("nonexistent-method")



..\test\test_watermarking_utilities.py:73: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



method = 'nonexistent-method'



    def get_method(method: str | WatermarkingMethod) -> WatermarkingMethod:

        """Resolve a method from a string name or pass-through an instance.

    

        Raises

        ------

        KeyError

            If ``method`` is a string not present in :data:`METHODS`.

        """

        if isinstance(method, WatermarkingMethod):

            return method

        try:

            return METHODS[method]

>       except CosmicRayTestingException as exc:

               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       NameError: name 'CosmicRayTestingException' is not defined



watermarking_utils.py:80: NameError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_get_method_invalid_name

1 failed, 41 passed, 23 warnings in 21.16s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -186,7 +186,7 @@
         for xref in range(1, xref_len):
             try:
                 s = doc.xref_object(xref, compressed=False) or ""
-            except Exception:
+            except CosmicRayTestingException:
                 s = ""
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
             # Type detection
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.27s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -203,7 +203,7 @@
 
         doc.close()
         return root
-    except Exception:
+    except CosmicRayTestingException:
         # Fallback: regex-based object scanning (no third-party deps)
         ...
 
.....................................F....                               [100%]

================================== FAILURES ===================================

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



pdf = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def explore_pdf(pdf: PdfSource) -> dict[str, Any]:

        """Return a JSON-serializable *tree* describing the PDF's nodes.

    

        The structure is deterministic for a given set of input bytes. When

        PyMuPDF (``fitz``) is available, the function uses the cross

        reference (xref) table to enumerate objects and page nodes. When not

        available, it falls back to scanning for ``obj`` / ``endobj`` blocks.

    

        The returned dictionary has the following shape (fields may be

        omitted when data is unavailable):

    

        .. code-block:: json

    

            {

              "id": "pdf:<sha1>",

              "type": "Document",

              "size": 12345,

              "children": [

                {"id": "page:0000", "type": "Page", ...},

                {"id": "obj:000001", "type": "XObject", ...}

              ]

            }

    

        Each node includes a deterministic ``id`` suitable as a "name node".

        """

        data = load_pdf_bytes(pdf)

    

        root: dict[str, Any] = {

            "id": f"pdf:{_sha1(data)}",

            "type": "Document",

            "size": len(data),

            "children": [],

        }

    

        try:

            import fitz  # type: ignore

    

>           doc = fitz.open(stream=data, filetype="pdf")

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



watermarking_utils.py:173: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\unittest\mock.py:1134: in __call__

    return self._mock_call(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\unittest\mock.py:1138: in _mock_call

    return self._execute_mock_call(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <MagicMock name='open' id='2832268198928'>, args = ()

kwargs = {'filetype': 'pdf', 'stream': b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages...00010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'}

effect = Exception('Forced fallback')



    def _execute_mock_call(self, /, *args, **kwargs):

        # separate from _increment_mock_call so that awaited functions are

        # executed separately from their call, also AsyncMock overrides this method

    

        effect = self.side_effect

        if effect is not None:

            if _is_exception(effect):

>               raise effect

E               Exception: Forced fallback



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\unittest\mock.py:1193: Exception



During handling of the above exception, another exception occurred:



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000293700F1A00>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def explore_pdf(pdf: PdfSource) -> dict[str, Any]:

        """Return a JSON-serializable *tree* describing the PDF's nodes.

    

        The structure is deterministic for a given set of input bytes. When

        PyMuPDF (``fitz``) is available, the function uses the cross

        reference (xref) table to enumerate objects and page nodes. When not

        available, it falls back to scanning for ``obj`` / ``endobj`` blocks.

    

        The returned dictionary has the following shape (fields may be

        omitted when data is unavailable):

    

        .. code-block:: json

    

            {

              "id": "pdf:<sha1>",

              "type": "Document",

              "size": 12345,

              "children": [

                {"id": "page:0000", "type": "Page", ...},

                {"id": "obj:000001", "type": "XObject", ...}

              ]

            }

    

        Each node includes a deterministic ``id`` suitable as a "name node".

        """

        data = load_pdf_bytes(pdf)

    

        root: dict[str, Any] = {

            "id": f"pdf:{_sha1(data)}",

            "type": "Document",

            "size": len(data),

            "children": [],

        }

    

        try:

            import fitz  # type: ignore

    

            doc = fitz.open(stream=data, filetype="pdf")

            # Pages as first-class nodes

            for page_index in range(doc.page_count):

                node = {

                    "id": f"page:{page_index:04d}",

                    "type": "Page",

                    "index": page_index,

                    "bbox": list(doc.load_page(page_index).bound()),  # [x0,y0,x1,y1]

                }

                root["children"].append(node)

    

            # XRef objects

            xref_len = doc.xref_length()

            for xref in range(1, xref_len):

                try:

                    s = doc.xref_object(xref, compressed=False) or ""

                except Exception:

                    s = ""

                s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""

                # Type detection

                m = _TYPE_RE.search(s_bytes)

                pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"

                node = {

                    "id": f"obj:{xref:06d}",

                    "type": pdf_type,

                    "xref": xref,

                    "is_stream": bool(doc.xref_is_stream(xref)),

                    "content_sha1": _sha1(s_bytes) if s_bytes else None,

                }

                root["children"].append(node)

    

            doc.close()

            return root

>       except CosmicRayTestingException:

               ^^^^^^^^^^^^^^^^^^^^^^^^^

E       NameError: name 'CosmicRayTestingException' is not defined



watermarking_utils.py:206: NameError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

1 failed, 41 passed, 23 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -183,7 +183,7 @@
 
         # XRef objects
         xref_len = doc.xref_length()
-        for xref in range(1, xref_len):
+        for xref in range( 2, xref_len):
             try:
                 s = doc.xref_object(xref, compressed=False) or ""
             except Exception:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -183,7 +183,7 @@
 
         # XRef objects
         xref_len = doc.xref_length()
-        for xref in range(1, xref_len):
+        for xref in range( 0, xref_len):
             try:
                 s = doc.xref_object(xref, compressed=False) or ""
             except Exception:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -191,7 +191,7 @@
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
             # Type detection
             m = _TYPE_RE.search(s_bytes)
-            pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"
+            pdf_type = m.group( 2).decode("ascii", "replace") if m else "Object"
             node = {
                 "id": f"obj:{xref:06d}",
                 "type": pdf_type,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -191,7 +191,7 @@
             s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""
             # Type detection
             m = _TYPE_RE.search(s_bytes)
-            pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"
+            pdf_type = m.group( 0).decode("ascii", "replace") if m else "Object"
             node = {
                 "id": f"obj:{xref:06d}",
                 "type": pdf_type,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.46s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -210,7 +210,7 @@
     # Regex fallback: enumerate uncompressed objects
     children: list[dict[str, Any]] = []
     for m in _OBJ_RE.finditer(data):
-        obj_num = int(m.group(1))
+        obj_num = int(m.group( 2))
         gen_num = int(m.group(2))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.71s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -210,7 +210,7 @@
     # Regex fallback: enumerate uncompressed objects
     children: list[dict[str, Any]] = []
     for m in _OBJ_RE.finditer(data):
-        obj_num = int(m.group(1))
+        obj_num = int(m.group( 0))
         gen_num = int(m.group(2))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
.FFF.F.F.FFF.........................F....                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215946476219Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T215947356583Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001FFFD181BE0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def explore_pdf(pdf: PdfSource) -> dict[str, Any]:

        """Return a JSON-serializable *tree* describing the PDF's nodes.

    

        The structure is deterministic for a given set of input bytes. When

        PyMuPDF (``fitz``) is available, the function uses the cross

        reference (xref) table to enumerate objects and page nodes. When not

        available, it falls back to scanning for ``obj`` / ``endobj`` blocks.

    

        The returned dictionary has the following shape (fields may be

        omitted when data is unavailable):

    

        .. code-block:: json

    

            {

              "id": "pdf:<sha1>",

              "type": "Document",

              "size": 12345,

              "children": [

                {"id": "page:0000", "type": "Page", ...},

                {"id": "obj:000001", "type": "XObject", ...}

              ]

            }

    

        Each node includes a deterministic ``id`` suitable as a "name node".

        """

        data = load_pdf_bytes(pdf)

    

        root: dict[str, Any] = {

            "id": f"pdf:{_sha1(data)}",

            "type": "Document",

            "size": len(data),

            "children": [],

        }

    

        try:

            import fitz  # type: ignore

    

            doc = fitz.open(stream=data, filetype="pdf")

            # Pages as first-class nodes

            for page_index in range(doc.page_count):

                node = {

                    "id": f"page:{page_index:04d}",

                    "type": "Page",

                    "index": page_index,

                    "bbox": list(doc.load_page(page_index).bound()),  # [x0,y0,x1,y1]

                }

                root["children"].append(node)

    

            # XRef objects

            xref_len = doc.xref_length()

            for xref in range(1, xref_len):

                try:

                    s = doc.xref_object(xref, compressed=False) or ""

                except Exception:

                    s = ""

                s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""

                # Type detection

                m = _TYPE_RE.search(s_bytes)

                pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"

                node = {

                    "id": f"obj:{xref:06d}",

                    "type": pdf_type,

                    "xref": xref,

                    "is_stream": bool(doc.xref_is_stream(xref)),

                    "content_sha1": _sha1(s_bytes) if s_bytes else None,

                }

                root["children"].append(node)

    

            doc.close()

            return root

        except Exception:

            # Fallback: regex-based object scanning (no third-party deps)

            ...

    

        # Regex fallback: enumerate uncompressed objects

        children: list[dict[str, Any]] = []

        for m in _OBJ_RE.finditer(data):

>           obj_num = int(m.group( 0))

                      ^^^^^^^^^^^^^^^^

E           ValueError: invalid literal for int() with base 10: b'1 0 obj'



watermarking_utils.py:213: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

9 failed, 33 passed, 23 warnings in 20.51s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -211,7 +211,7 @@
     children: list[dict[str, Any]] = []
     for m in _OBJ_RE.finditer(data):
         obj_num = int(m.group(1))
-        gen_num = int(m.group(2))
+        gen_num = int(m.group( 3))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
         end = end_match.start() if end_match else start
.....................................F....                               [100%]

================================== FAILURES ===================================

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000241C6549E20>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def explore_pdf(pdf: PdfSource) -> dict[str, Any]:

        """Return a JSON-serializable *tree* describing the PDF's nodes.

    

        The structure is deterministic for a given set of input bytes. When

        PyMuPDF (``fitz``) is available, the function uses the cross

        reference (xref) table to enumerate objects and page nodes. When not

        available, it falls back to scanning for ``obj`` / ``endobj`` blocks.

    

        The returned dictionary has the following shape (fields may be

        omitted when data is unavailable):

    

        .. code-block:: json

    

            {

              "id": "pdf:<sha1>",

              "type": "Document",

              "size": 12345,

              "children": [

                {"id": "page:0000", "type": "Page", ...},

                {"id": "obj:000001", "type": "XObject", ...}

              ]

            }

    

        Each node includes a deterministic ``id`` suitable as a "name node".

        """

        data = load_pdf_bytes(pdf)

    

        root: dict[str, Any] = {

            "id": f"pdf:{_sha1(data)}",

            "type": "Document",

            "size": len(data),

            "children": [],

        }

    

        try:

            import fitz  # type: ignore

    

            doc = fitz.open(stream=data, filetype="pdf")

            # Pages as first-class nodes

            for page_index in range(doc.page_count):

                node = {

                    "id": f"page:{page_index:04d}",

                    "type": "Page",

                    "index": page_index,

                    "bbox": list(doc.load_page(page_index).bound()),  # [x0,y0,x1,y1]

                }

                root["children"].append(node)

    

            # XRef objects

            xref_len = doc.xref_length()

            for xref in range(1, xref_len):

                try:

                    s = doc.xref_object(xref, compressed=False) or ""

                except Exception:

                    s = ""

                s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""

                # Type detection

                m = _TYPE_RE.search(s_bytes)

                pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"

                node = {

                    "id": f"obj:{xref:06d}",

                    "type": pdf_type,

                    "xref": xref,

                    "is_stream": bool(doc.xref_is_stream(xref)),

                    "content_sha1": _sha1(s_bytes) if s_bytes else None,

                }

                root["children"].append(node)

    

            doc.close()

            return root

        except Exception:

            # Fallback: regex-based object scanning (no third-party deps)

            ...

    

        # Regex fallback: enumerate uncompressed objects

        children: list[dict[str, Any]] = []

        for m in _OBJ_RE.finditer(data):

            obj_num = int(m.group(1))

>           gen_num = int(m.group( 3))

                          ^^^^^^^^^^^

E           IndexError: no such group



watermarking_utils.py:214: IndexError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

1 failed, 41 passed, 23 warnings in 20.90s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -211,7 +211,7 @@
     children: list[dict[str, Any]] = []
     for m in _OBJ_RE.finditer(data):
         obj_num = int(m.group(1))
-        gen_num = int(m.group(2))
+        gen_num = int(m.group( 1))
         start = m.end()
         end_match = _ENDOBJ_RE.search(data, start)
         end = end_match.start() if end_match else start
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -218,7 +218,7 @@
         slice_bytes = data[start:end]
         # Guess type
         t = _TYPE_RE.search(slice_bytes)
-        pdf_type = t.group(1).decode("ascii", "replace") if t else "Object"
+        pdf_type = t.group( 2).decode("ascii", "replace") if t else "Object"
         node = {
             "id": f"obj:{obj_num:06d}:{gen_num:05d}",
             "type": pdf_type,
.....................................F....                               [100%]

================================== FAILURES ===================================

________ TestWatermarkingUtils.test_explore_pdf_fallback_without_fitz _________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x0000018797FD9DF0>

sample_pdf_bytes = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def test_explore_pdf_fallback_without_fitz(self, sample_pdf_bytes):

        """Test explore_pdf fallback when fitz is not available."""

        # Since fitz is actually available in our environment, we need to test

        # the fallback differently. We'll test that the function works even if

        # fitz import fails internally

    

        # Force the fallback by causing fitz.open to raise an exception

        with patch("fitz.open", side_effect=Exception("Forced fallback")):

>           result = WMUtils.explore_pdf(sample_pdf_bytes)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_utilities.py:215: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf = b'%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nen...000010 00000 n \n0000000060 00000 n \n0000000120 00000 n \ntrailer\n<< /Size 4 /Root 1 0 R >>\nstartxref\n180\n%%EOF\n'



    def explore_pdf(pdf: PdfSource) -> dict[str, Any]:

        """Return a JSON-serializable *tree* describing the PDF's nodes.

    

        The structure is deterministic for a given set of input bytes. When

        PyMuPDF (``fitz``) is available, the function uses the cross

        reference (xref) table to enumerate objects and page nodes. When not

        available, it falls back to scanning for ``obj`` / ``endobj`` blocks.

    

        The returned dictionary has the following shape (fields may be

        omitted when data is unavailable):

    

        .. code-block:: json

    

            {

              "id": "pdf:<sha1>",

              "type": "Document",

              "size": 12345,

              "children": [

                {"id": "page:0000", "type": "Page", ...},

                {"id": "obj:000001", "type": "XObject", ...}

              ]

            }

    

        Each node includes a deterministic ``id`` suitable as a "name node".

        """

        data = load_pdf_bytes(pdf)

    

        root: dict[str, Any] = {

            "id": f"pdf:{_sha1(data)}",

            "type": "Document",

            "size": len(data),

            "children": [],

        }

    

        try:

            import fitz  # type: ignore

    

            doc = fitz.open(stream=data, filetype="pdf")

            # Pages as first-class nodes

            for page_index in range(doc.page_count):

                node = {

                    "id": f"page:{page_index:04d}",

                    "type": "Page",

                    "index": page_index,

                    "bbox": list(doc.load_page(page_index).bound()),  # [x0,y0,x1,y1]

                }

                root["children"].append(node)

    

            # XRef objects

            xref_len = doc.xref_length()

            for xref in range(1, xref_len):

                try:

                    s = doc.xref_object(xref, compressed=False) or ""

                except Exception:

                    s = ""

                s_bytes = s.encode("latin-1", "replace") if isinstance(s, str) else b""

                # Type detection

                m = _TYPE_RE.search(s_bytes)

                pdf_type = m.group(1).decode("ascii", "replace") if m else "Object"

                node = {

                    "id": f"obj:{xref:06d}",

                    "type": pdf_type,

                    "xref": xref,

                    "is_stream": bool(doc.xref_is_stream(xref)),

                    "content_sha1": _sha1(s_bytes) if s_bytes else None,

                }

                root["children"].append(node)

    

            doc.close()

            return root

        except Exception:

            # Fallback: regex-based object scanning (no third-party deps)

            ...

    

        # Regex fallback: enumerate uncompressed objects

        children: list[dict[str, Any]] = []

        for m in _OBJ_RE.finditer(data):

            obj_num = int(m.group(1))

            gen_num = int(m.group(2))

            start = m.end()

            end_match = _ENDOBJ_RE.search(data, start)

            end = end_match.start() if end_match else start

            slice_bytes = data[start:end]

            # Guess type

            t = _TYPE_RE.search(slice_bytes)

>           pdf_type = t.group( 2).decode("ascii", "replace") if t else "Object"

                       ^^^^^^^^^^^

E           IndexError: no such group



watermarking_utils.py:221: IndexError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_explore_pdf_fallback_without_fitz

1 failed, 41 passed, 23 warnings in 21.22s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -218,7 +218,7 @@
         slice_bytes = data[start:end]
         # Guess type
         t = _TYPE_RE.search(slice_bytes)
-        pdf_type = t.group(1).decode("ascii", "replace") if t else "Object"
+        pdf_type = t.group( 0).decode("ascii", "replace") if t else "Object"
         node = {
             "id": f"obj:{obj_num:06d}:{gen_num:05d}",
             "type": pdf_type,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -172,7 +172,7 @@
 
         doc = fitz.open(stream=data, filetype="pdf")
         # Pages as first-class nodes
-        for page_index in range(doc.page_count):
+        for page_index in []:
             node = {
                 "id": f"page:{page_index:04d}",
                 "type": "Page",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -183,7 +183,7 @@
 
         # XRef objects
         xref_len = doc.xref_length()
-        for xref in range(1, xref_len):
+        for xref in []:
             try:
                 s = doc.xref_object(xref, compressed=False) or ""
             except Exception:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.27s

operator: core/ZeroIterationForLoop, occurrence: 2
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -209,7 +209,7 @@
 
     # Regex fallback: enumerate uncompressed objects
     children: list[dict[str, Any]] = []
-    for m in _OBJ_RE.finditer(data):
+    for m in []:
         obj_num = int(m.group(1))
         gen_num = int(m.group(2))
         start = m.end()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ZeroIterationForLoop, occurrence: 3
--- mutation diff ---
--- awatermarking_utils.py
+++ bwatermarking_utils.py
@@ -230,7 +230,7 @@
 
     # Also derive simple page nodes by searching for '/Type /Page'
     page_nodes = [c for c in children if c.get("type") == "Page"]
-    for i, c in enumerate(page_nodes):
+    for i, c in []:
         # Provide deterministic page IDs independent from object numbers
         c_page = {
             "id": f"page:{i:04d}",
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " - intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for -: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000227861B77A0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000227850DD340>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000227850DD340>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " - intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for -: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000227861B7D10>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000227850DD340>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-192/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000227850DD340>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " - intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for -: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.54s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for - "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for -: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001EA0F1DB200>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001EA0E10CC50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001EA0E10CC50>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for - "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for -: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001EA0F1DB770>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001EA0E10CC50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-742/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001EA0E10CC50>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for - "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for -: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " * intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: can't multiply sequence by non-int of type 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000252BF467890>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000252BE39D370>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000252BE39D370>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " * intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: can't multiply sequence by non-int of type 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000252BF467E00>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000252BE39D370>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-139/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000252BE39D370>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " * intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: can't multiply sequence by non-int of type 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for * "\nDo not disclose"
         )
 
         if not secret:
.FFFFFFF.FFF.......F..F...................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195449874444Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195450718873Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000214D76CB470>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000214D4B26C00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000214D4B26C00>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for * "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: can't multiply sequence by non-int of type 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000214D76CB9E0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000214D4B26C00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1694/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000214D4B26C00>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for * "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: can't multiply sequence by non-int of type 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

12 failed, 30 passed, 23 warnings in 20.04s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " / intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for /: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001746E50B650>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001746D530140>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001746D530140>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " / intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001746E50BBC0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001746D530140>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-738/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001746D530140>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " / intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.58s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for / "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for /: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000286770AB620>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000028675FDCE60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000028675FDCE60>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for / "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000286770ABB90>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000028675FDCE60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2059/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000028675FDCE60>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for / "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for /: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.45s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " // intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for //: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002A82E6DB350>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002A82D63E990>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002A82D63E990>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " // intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for //: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002A82E6DB8C0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002A82D63E990>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1933/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002A82D63E990>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " // intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for //: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.57s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for // "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for //: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001824DEF77A0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001824CE39430>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001824CE39430>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for // "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for //: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001824DEF7D10>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001824CE39430>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2435/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001824CE39430>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for // "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for //: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " % intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: not all arguments converted during string formatting

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001CFAE0FB620>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001CFAD01D2E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001CFAD01D2E0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " % intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: not all arguments converted during string formatting



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001CFAE0FBB90>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001CFAD01D2E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1334/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001CFAD01D2E0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " % intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: not all arguments converted during string formatting



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.62s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for % "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: not all arguments converted during string formatting

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000242EF6E77A0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000242ED5422D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000242ED5422D0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for % "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: not all arguments converted during string formatting



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000242EF6E7D10>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000242ED5422D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1999/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000242ED5422D0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for % "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: not all arguments converted during string formatting



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.59s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " ** intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for ** or pow(): 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000023F8449B590>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023F833A9160>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023F833A9160>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " ** intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000023F8449BB00>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023F833A9160>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-757/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023F833A9160>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " ** intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.59s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for ** "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for ** or pow(): 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000143FA1975F0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000143F90C9550>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000143F90C9550>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for ** "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000143FA197B60>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000143F90C9550>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1875/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000143F90C9550>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for ** "\nDo not disclose"

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.67s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " >> intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for >>: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000027FF4617680>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027FF354D3A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027FF354D3A0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " >> intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for >>: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000027FF4617BF0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027FF354D3A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-826/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027FF354D3A0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " >> intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for >>: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.52s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for >> "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for >>: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002374618B410>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023745007D40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023745007D40>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for >> "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for >>: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002374618B980>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023745007D40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1697/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000023745007D40>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for >> "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for >>: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " << intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for <<: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002679AB1B4D0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002679998CD40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002679998CD40>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " << intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for <<: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002679AB1BA40>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002679998CD40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-197/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002679998CD40>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " << intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for <<: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.60s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for << "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for <<: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001D4D2A77800>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D4D19A95B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D4D19A95B0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for << "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for <<: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001D4D2A77D70>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D4D19A95B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1988/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001D4D19A95B0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for << "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for <<: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.66s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " | intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for |: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000016D09B4B3E0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000016D08A58E90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000016D08A58E90>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " | intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for |: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000016D09B4B950>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000016D08A58E90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-407/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000016D08A58E90>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " | intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for |: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for | "\nDo not disclose"
         )
 
         if not secret:
.FFFFF.F.FFF.......F..F...................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T154801663940Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T154802491129Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000238AA6FB5F0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000238A9631130>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000238A9631130>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for | "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for |: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000238AA6FBB60>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000238A9631130>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1022/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000238A9631130>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for | "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for |: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

11 failed, 31 passed, 23 warnings in 20.04s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " & intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for &: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BCD29FB6B0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001BCCFB02F00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001BCCFB02F00>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " & intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for &: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BCD29FBC20>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001BCCFB02F00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-90/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001BCCFB02F00>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " & intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for &: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.60s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for & "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for &: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022BDC83B6B0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022BDB75D2E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022BDB75D2E0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for & "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for &: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022BDC83BC20>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022BDB75D2E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-270/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022BDB75D2E0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for & "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for &: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.49s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " ^ intended_for + "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for ^: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B72E4DB710>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B72B92A630>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B72B92A630>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " ^ intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for ^: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B72E4DBC80>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B72B92A630>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1773/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B72B92A630>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " ^ intended_for + "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for ^: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.35s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -99,7 +99,7 @@
         if not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
-            data, "Intended for: " + intended_for + "\nDo not disclose"
+            data, "Intended for: " + intended_for ^ "\nDo not disclose"
         )
 
         if not secret:
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: unsupported operand type(s) for ^: 'str' and 'str'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000208D2A0B740>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000208D19493A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000208D19493A0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for ^ "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for ^: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000208D2A0BCB0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000208D19493A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2021/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000208D19493A0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

>           data, "Intended for: " + intended_for ^ "\nDo not disclose"

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        )

E       TypeError: unsupported operand type(s) for ^: 'str' and 'str'



structural_and_overlay_watermark.py:102: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 21.76s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str + None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T22:23:28+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:23:28+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T22:23:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:23:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str + None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.16s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str + None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T20:56:54+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:56:54+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T20:56:55+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:56:55+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str + None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.15s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str + None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:48:25+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:48:25+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-18T00:48:26+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:48:26+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str + None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for +: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for +: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.18s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str - None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T20:30:26+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:30:26+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T20:30:27+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:30:27+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str - None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.20s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str - None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T19:37:20+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:37:20+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T19:37:21+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:37:21+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str - None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.13s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str - None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:40:07+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:40:07+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T12:40:08+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:40:08+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str - None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for -: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for -: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.26s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str * None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T22:29:09+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:29:10+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T22:29:11+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:29:11+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str * None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.23s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str * None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T21:19:03+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T21:19:03+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T21:19:04+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T21:19:04+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str * None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.21s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str * None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T01:26:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:26:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T01:27:00+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:27:00+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str * None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for *: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for *: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.25s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str / None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:54:35+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:54:35+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T12:54:36+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:54:36+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str / None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.14s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str / None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T12:46:22+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:46:22+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T12:46:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T12:46:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str / None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.23s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str / None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T11:52:09+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T11:52:09+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T11:52:10+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T11:52:10+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str / None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for /: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for /: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.65s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str // None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T19:05:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:05:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-17T19:05:25+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:05:25+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str // None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.06s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str // None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T19:21:05+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:21:05+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T19:21:06+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T19:21:06+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str // None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.12s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str // None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T02:11:27+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T02:11:27+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T02:11:28+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T02:11:28+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str // None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for //: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for //: 't...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.49s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str % None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T14:05:28+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T14:05:28+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T14:05:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T14:05:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str % None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.31s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str % None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T02:00:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T02:00:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T02:00:24+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T02:00:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str % None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.46s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str % None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T15:50:18+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:50:18+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T15:50:19+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T15:50:20+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str % None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for %: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for %: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.12s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str ** None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T14:43:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T14:43:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T14:43:24+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T14:43:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str ** None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.26s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str ** None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T20:19:42+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:19:42+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-17T20:19:43+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T20:19:43+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str ** None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.02s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str ** None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:02:26+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:02:26+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T00:02:27+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:02:27+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str ** None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ** or pow(): 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ** or ...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.25s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str >> None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T01:05:47+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:05:47+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T01:05:48+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:05:48+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str >> None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.14s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str >> None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T13:46:42+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T13:46:42+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T13:46:43+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T13:46:43+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str >> None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.14s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str >> None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T14:17:23+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T14:17:23+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T14:17:24+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T14:17:24+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str >> None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for >>: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for >>: 't...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.25s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str << None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T18:17:37+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:17:37+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Network softsec-tatou_default  Removed

time="2025-10-17T18:17:38+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:17:39+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str << None = None,

                  ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.19s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str << None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T01:36:34+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:36:34+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T01:36:35+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:36:35+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str << None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.23s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str << None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T00:02:39+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:02:40+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T00:02:41+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T00:02:41+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str << None = None,

              ^^^^^^^^^^^

E   TypeError: unsupported operand type(s) for <<: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for <<: 't...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.10s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str & None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T22:08:11+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:08:11+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T22:08:12+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T22:08:12+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str & None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.08s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str & None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T18:26:58+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:26:58+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T18:26:59+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:26:59+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str & None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.23s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str & None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T17:39:08+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:39:08+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-17T17:39:09+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T17:39:09+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str & None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for &: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for &: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.25s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -89,7 +89,7 @@
         pdf,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str ^ None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T01:07:49+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:07:49+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removed

time="2025-10-18T01:07:50+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T01:07:50+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:92: in StructuralOverlay

    intended_for: str ^ None = None,

                  ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.08s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -90,7 +90,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         data = load_pdf_bytes(pdf)
         # Add a visible watermark. This might confuse the attackers,

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str ^ None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-17T18:13:28+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:13:28+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-17T18:13:29+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-17T18:13:29+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:93: in StructuralOverlay

    position: str ^ None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 13.40s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -122,7 +122,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         return True
 

=================================== ERRORS ====================================

______________________ ERROR collecting test/test_api.py ______________________

..\test\test_api.py:33: in <module>

    from server import create_app

server.py:16: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str ^ None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

------------------------------- Captured stdout -------------------------------

Preparing the environment...

Waiting for db to be ready...

------------------------------- Captured stderr -------------------------------

time="2025-10-18T02:03:07+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T02:03:07+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Container softsec-tatou-db-1  Stopping

 Container softsec-tatou-db-1  Stopped

 Container softsec-tatou-db-1  Removing

 Container softsec-tatou-db-1  Removed

 Volume softsec-tatou_user-files  Removing

 Volume softsec-tatou_grafana-data  Removing

 Volume softsec-tatou_db-data  Removing

 Volume softsec-tatou_grafana-data  Resource is still in use

 Volume softsec-tatou_user-files  Resource is still in use

 Network softsec-tatou_default  Removing

 Volume softsec-tatou_db-data  Removed

 Network softsec-tatou_default  Removed

time="2025-10-18T02:03:11+02:00" level=warning msg="The \"METRICS_TOKEN\" variable is not set. Defaulting to a blank string."

time="2025-10-18T02:03:11+02:00" level=warning msg="The \"SECRET_KEY\" variable is not set. Defaulting to a blank string."

 Network softsec-tatou_default  Creating

 Network softsec-tatou_default  Created

 Volume "softsec-tatou_db-data"  Creating

 Volume "softsec-tatou_db-data"  Created

 Container softsec-tatou-db-1  Creating

 Container softsec-tatou-db-1  Created

 Container softsec-tatou-db-1  Starting

 Container softsec-tatou-db-1  Started

____________ ERROR collecting test/test_watermarking_utilities.py _____________

..\test\test_watermarking_utilities.py:7: in <module>

    import watermarking_utils as WMUtils

watermarking_utils.py:38: in <module>

    from structural_and_overlay_watermark import StructuralOverlay

structural_and_overlay_watermark.py:24: in <module>

    class StructuralOverlay(WatermarkingMethod):

structural_and_overlay_watermark.py:125: in StructuralOverlay

    position: str ^ None = None,

              ^^^^^^^^^^

E   TypeError: unsupported operand type(s) for ^: 'type' and 'NoneType'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

ERROR ..\test\test_api.py - TypeError: unsupported operand type(s) for ^: 'ty...

ERROR ..\test\test_watermarking_utilities.py - TypeError: unsupported operand...

!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!

1 skipped, 7 warnings, 2 errors in 16.30s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -96,7 +96,7 @@
         # Add a visible watermark. This might confuse the attackers,
         # suggesting that the only watermark is the visible watermark.
         # It also works as a deterrent against document diffusion.
-        if not intended_for:
+        if  intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
             data, "Intended for: " + intended_for + "\nDo not disclose"
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Missing recipient. (intended_for)

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000014405B2B440>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000014403982240>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000014403982240>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if  intended_for:

>           raise ValueError("Missing recipient. (intended_for)")

E           ValueError: Missing recipient. (intended_for)



structural_and_overlay_watermark.py:100: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000014405B2B9B0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000014403982240>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1273/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000014403982240>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if  intended_for:

>           raise ValueError("Missing recipient. (intended_for)")

E           ValueError: Missing recipient. (intended_for)



structural_and_overlay_watermark.py:100: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.49s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -102,7 +102,7 @@
             data, "Intended for: " + intended_for + "\nDo not disclose"
         )
 
-        if not secret:
+        if  secret:
             raise ValueError("Secret must be a non-empty string")
         if not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
.FFFFFFF.FFF.......F..F...................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T103124989068Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T103125837686Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B9FE427650>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B9FD35D220>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B9FD35D220>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if  secret:

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



structural_and_overlay_watermark.py:106: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B9FE427BC0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B9FD35D220>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-165/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B9FD35D220>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if  secret:

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



structural_and_overlay_watermark.py:106: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

12 failed, 30 passed, 23 warnings in 20.13s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -104,7 +104,7 @@
 
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if  isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
 
         # Add the "real" watermark by embedding the secret into
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Key must be a non-empty string

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002DFBB24B680>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002DFB90EFF50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002DFB90EFF50>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if  isinstance(key, str) or not key:

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



structural_and_overlay_watermark.py:108: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002DFBB24BBF0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002DFB90EFF50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1452/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002DFB90EFF50>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if  isinstance(key, str) or not key:

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



structural_and_overlay_watermark.py:108: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.81s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -104,7 +104,7 @@
 
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if not isinstance(key, str) or  key:
             raise ValueError("Key must be a non-empty string")
 
         # Add the "real" watermark by embedding the secret into
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Key must be a non-empty string

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000027C7C3F7710>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027C7B434050>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027C7B434050>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if not isinstance(key, str) or  key:

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



structural_and_overlay_watermark.py:108: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000027C7C3F7C80>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027C7B434050>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-390/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027C7B434050>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if not isinstance(key, str) or  key:

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



structural_and_overlay_watermark.py:108: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.65s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -96,7 +96,7 @@
         # Add a visible watermark. This might confuse the attackers,
         # suggesting that the only watermark is the visible watermark.
         # It also works as a deterrent against document diffusion.
-        if not intended_for:
+        if not not intended_for:
             raise ValueError("Missing recipient. (intended_for)")
         visibly_watermarked = self.visible_watermark(
             data, "Intended for: " + intended_for + "\nDo not disclose"
.FFFFFFF.FFF.......F..F...................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195719966744Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T195720863496Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000027998AFB560>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027997A191C0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027997A191C0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not not intended_for:

>           raise ValueError("Missing recipient. (intended_for)")

E           ValueError: Missing recipient. (intended_for)



structural_and_overlay_watermark.py:100: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000027998AFBAD0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027997A191C0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1701/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000027997A191C0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not not intended_for:

>           raise ValueError("Missing recipient. (intended_for)")

E           ValueError: Missing recipient. (intended_for)



structural_and_overlay_watermark.py:100: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

12 failed, 30 passed, 23 warnings in 19.97s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -102,7 +102,7 @@
             data, "Intended for: " + intended_for + "\nDo not disclose"
         )
 
-        if not secret:
+        if not not secret:
             raise ValueError("Secret must be a non-empty string")
         if not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Secret must be a non-empty string

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002B995DD7770>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002B993181A60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002B993181A60>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not not secret:

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



structural_and_overlay_watermark.py:106: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002B995DD7CE0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002B993181A60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1298/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002B993181A60>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not not secret:

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



structural_and_overlay_watermark.py:106: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.67s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -104,7 +104,7 @@
 
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if not not isinstance(key, str) or not key:
             raise ValueError("Key must be a non-empty string")
 
         # Add the "real" watermark by embedding the secret into
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Key must be a non-empty string

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C88D35B470>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001C88C288EC0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001C88C288EC0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if not not isinstance(key, str) or not key:

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



structural_and_overlay_watermark.py:108: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C88D35B9E0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001C88C288EC0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1315/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001C88C288EC0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if not not isinstance(key, str) or not key:

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



structural_and_overlay_watermark.py:108: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.57s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -150,7 +150,7 @@
         for page in reader.pages:
             # Check for our custom structural watermark
             watermark_obj = page.get("/PieceInfo")
-            if watermark_obj and obfuscated_key in watermark_obj:
+            if not watermark_obj and obfuscated_key in watermark_obj:
                 hidden = watermark_obj[obfuscated_key]
                 # Extract string
                 encrypted_str = str(hidden)
..........F...........F...................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: argument of type 'NoneType' is not iterable

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001AFA3D0B920>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001AFA2C38CE0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-465/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

        extracted = wm_impl.read_secret(out_pdf, key=key)

        assert isinstance(extracted, str), f"{method_name}: read_secret must return str"  # nosec B101

>       assert extracted == secret, (  # nosec B101

            f"{method_name}: read_secret should return the exact embedded secret"

        )

E       AssertionError: overlay-watermark: read_secret should return the exact embedded secret

E       assert 'None' == 'unit-test-secret'

E         

E         - unit-test-secret

E         + None



..\test\test_watermarking_all_methods.py:129: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

2 failed, 40 passed, 23 warnings in 21.28s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -45,7 +45,7 @@
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
-                overlay=True,
+                overlay=False,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
                 stroke_opacity=0.5,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -124,7 +124,7 @@
         pdf: PdfSource,
         position: str | None = None,
     ) -> bool:
-        return True
+        return False
 
     @staticmethod
     def derive_fernet_key(password: str) -> bytes:
.........F......s..s..s...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 400 == 201

1 failed, 38 passed, 3 skipped, 23 warnings in 20.73s

operator: core/ReplaceAndWithOr, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -150,7 +150,7 @@
         for page in reader.pages:
             # Check for our custom structural watermark
             watermark_obj = page.get("/PieceInfo")
-            if watermark_obj and obfuscated_key in watermark_obj:
+            if watermark_obj or obfuscated_key in watermark_obj:
                 hidden = watermark_obj[obfuscated_key]
                 # Extract string
                 encrypted_str = str(hidden)
..........F...............................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: argument of type 'NoneType' is not iterable

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

1 failed, 41 passed, 23 warnings in 21.07s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -74,7 +74,7 @@
         obfuscated_key = NameObject("/XObjD5fA2e1")
 
         for page in reader.pages:
-            piece_info = page.get("/PieceInfo") or DictionaryObject()
+            piece_info = page.get("/PieceInfo") and DictionaryObject()
             piece_info.update({obfuscated_key: create_string_object(hidden_data)})
             page[NameObject("/PieceInfo")] = piece_info
             writer.add_page(page)
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: 'NoneType' object has no attribute 'update'

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000208E6BC76E0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000208E49DE0C0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:116: in add_watermark

    fully_watermarked = self.structural_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf_bytes = b'%PDF-1.5\n%\xc2\xb5\xc2\xb6\n\n1 0 obj\n<</Type/Page/Parent 7 0 R/Resources 19 0 R/MediaBox[0 0 595.30398 841.8898]/... 0 R/Root 20 0 R/ID[<131B47C29D42EE0998F8FBFA411127C3><08E57B27FFC3872CC0B4ACCCCB6603AE>]>>\nstartxref\n38616\n%%EOF\n'

hidden_data = 'gAAAAABo8qeWBuJE5SeAEfBHOZ_OJanzAx8fGBse8BREypKEcEXR8uuc11eYzxjDqGdAaeMDjO6Q-GUkxD9RDKsIqvNuO2EcqjURf0Oxnh8G9rHz7daS5OY='



    @staticmethod

    def structural_watermark(pdf_bytes: bytes, hidden_data: str) -> bytes:

        """

        Adds a hidden structural watermark to the PDF (in-memory).

        Embeds hidden data in each page's dictionary.

        Returns the updated PDF as bytes.

        """

        input_stream = BytesIO(pdf_bytes)

        reader = PdfReader(input_stream)

        writer = PdfWriter()

    

        # Creating an incospicuous location to hide the watermark.

        # Adding in /PieceInfo (app. specific metadata)

        # Obfuscated name makes it less obvious than "/Watermark"

        obfuscated_key = NameObject("/XObjD5fA2e1")

    

        for page in reader.pages:

            piece_info = page.get("/PieceInfo") and DictionaryObject()

>           piece_info.update({obfuscated_key: create_string_object(hidden_data)})

            ^^^^^^^^^^^^^^^^^

E           AttributeError: 'NoneType' object has no attribute 'update'



structural_and_overlay_watermark.py:78: AttributeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000208E6BC7C50>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000208E49DE0C0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1788/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:116: in add_watermark

    fully_watermarked = self.structural_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf_bytes = b'%PDF-1.5\n%\xc2\xb5\xc2\xb6\n\n1 0 obj\n<</Type/Page/Parent 7 0 R/Resources 19 0 R/MediaBox[0 0 595.30398 841.8898]/... 0 R/Root 20 0 R/ID[<131B47C29D42EE0998F8FBFA411127C3><4F7AD89FE9F09A839C1F5CCE420924C9>]>>\nstartxref\n38616\n%%EOF\n'

hidden_data = 'gAAAAABo8qeWWeWH7QhIa6AW0RaVk4HT7N3nhBZ0Tx8vQwpUjSVTluNyPZibS26vwXCDUGRzMoLo-rwS4uYxqhk4O7dXWpg_ri90nAi1KkZakflWNQl37vw='



    @staticmethod

    def structural_watermark(pdf_bytes: bytes, hidden_data: str) -> bytes:

        """

        Adds a hidden structural watermark to the PDF (in-memory).

        Embeds hidden data in each page's dictionary.

        Returns the updated PDF as bytes.

        """

        input_stream = BytesIO(pdf_bytes)

        reader = PdfReader(input_stream)

        writer = PdfWriter()

    

        # Creating an incospicuous location to hide the watermark.

        # Adding in /PieceInfo (app. specific metadata)

        # Obfuscated name makes it less obvious than "/Watermark"

        obfuscated_key = NameObject("/XObjD5fA2e1")

    

        for page in reader.pages:

            piece_info = page.get("/PieceInfo") and DictionaryObject()

>           piece_info.update({obfuscated_key: create_string_object(hidden_data)})

            ^^^^^^^^^^^^^^^^^

E           AttributeError: 'NoneType' object has no attribute 'update'



structural_and_overlay_watermark.py:78: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 21.06s

operator: core/ReplaceOrWithAnd, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -104,7 +104,7 @@
 
         if not secret:
             raise ValueError("Secret must be a non-empty string")
-        if not isinstance(key, str) or not key:
+        if not isinstance(key, str) and not key:
             raise ValueError("Key must be a non-empty string")
 
         # Add the "real" watermark by embedding the secret into
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 22.69s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -161,7 +161,7 @@
                     fernet = Fernet(derived_key)
                     decrypted = fernet.decrypt(encrypted_str.encode()).decode()
                     extracted_data.append(decrypted)
-                except InvalidToken as e:
+                except CosmicRayTestingException as e:
                     raise InvalidKeyError("Failed to decrypt watermark") from e
             else:
                 extracted_data.append(None)  # No watermark found on this page
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -39,7 +39,7 @@
 
         for page in doc:
             page.insert_text(
-                (72, 72),  # Top-left corner (x, y)
+                ( 73, 72),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -39,7 +39,7 @@
 
         for page in doc:
             page.insert_text(
-                (72, 72),  # Top-left corner (x, y)
+                ( 71, 72),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.29s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -39,7 +39,7 @@
 
         for page in doc:
             page.insert_text(
-                (72, 72),  # Top-left corner (x, y)
+                (72, 73),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -39,7 +39,7 @@
 
         for page in doc:
             page.insert_text(
-                (72, 72),  # Top-left corner (x, y)
+                (72, 71),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -41,7 +41,7 @@
             page.insert_text(
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
-                fontsize=18,
+                fontsize= 19,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -41,7 +41,7 @@
             page.insert_text(
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
-                fontsize=18,
+                fontsize= 17,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -42,7 +42,7 @@
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
-                rotate=0,
+                rotate= 1,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: bad rotate value

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002A99E4378F0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002A99D4D8080>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymupdf.utils.Shape object at 0x000002A99E41DF70>

point = Point(72.0, 72.0)

buffer = 'Intended for: unit-test-recipient\nDo not disclose'



    def insert_text(

        self,

        point: point_like,

        buffer: typing.Union[str, list],

        *,

        fontsize: float = 11,

        lineheight: OptFloat = None,

        fontname: str = "helv",

        fontfile: OptStr = None,

        set_simple: bool = 0,

        encoding: int = 0,

        color: OptSeq = None,

        fill: OptSeq = None,

        render_mode: int = 0,

        border_width: float = 0.05,

        miter_limit: float = 1,

        rotate: int = 0,

        morph: OptSeq = None,

        stroke_opacity: float = 1,

        fill_opacity: float = 1,

        oc: int = 0,

    ) -> int:

    

        # ensure 'text' is a list of strings, worth dealing with

        if not bool(buffer):

            return 0

    

        if type(buffer) not in (list, tuple):

            text = buffer.splitlines()

        else:

            text = buffer

    

        if not len(text) > 0:

            return 0

    

        point = pymupdf.Point(point)

        try:

            maxcode = max([ord(c) for c in " ".join(text)])

        except Exception:

            pymupdf.exception_info()

            return 0

    

        # ensure valid 'fontname'

        fname = fontname

        if fname.startswith("/"):

            fname = fname[1:]

    

        xref = self.page.insert_font(

            fontname=fname, fontfile=fontfile, encoding=encoding, set_simple=set_simple

        )

        fontinfo = pymupdf.CheckFontInfo(self.doc, xref)

    

        fontdict = fontinfo[1]

        ordering = fontdict["ordering"]

        simple = fontdict["simple"]

        bfname = fontdict["name"]

        ascender = fontdict["ascender"]

        descender = fontdict["descender"]

        if lineheight:

            lheight = fontsize * lineheight

        elif ascender - descender <= 1:

            lheight = fontsize * 1.2

        else:

            lheight = fontsize * (ascender - descender)

    

        if maxcode > 255:

            glyphs = self.doc.get_char_widths(xref, maxcode + 1)

        else:

            glyphs = fontdict["glyphs"]

    

        tab = []

        for t in text:

            if simple and bfname not in ("Symbol", "ZapfDingbats"):

                g = None

            else:

                g = glyphs

            tab.append(pymupdf.getTJstr(t, g, simple, ordering))

        text = tab

    

        color_str = pymupdf.ColorCode(color, "c")

        fill_str = pymupdf.ColorCode(fill, "f")

        if not fill and render_mode == 0:  # ensure fill color when 0 Tr

            fill = color

            fill_str = pymupdf.ColorCode(color, "f")

    

        morphing = pymupdf.CheckMorph(morph)

        rot = rotate

        if rot % 90 != 0:

>           raise ValueError("bad rotate value")

E           ValueError: bad rotate value



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3631: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002A99E437E60>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002A99D4D8080>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2335/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymupdf.utils.Shape object at 0x000002A99E90E8A0>

point = Point(72.0, 72.0)

buffer = 'Intended for: unit-test-recipient\nDo not disclose'



    def insert_text(

        self,

        point: point_like,

        buffer: typing.Union[str, list],

        *,

        fontsize: float = 11,

        lineheight: OptFloat = None,

        fontname: str = "helv",

        fontfile: OptStr = None,

        set_simple: bool = 0,

        encoding: int = 0,

        color: OptSeq = None,

        fill: OptSeq = None,

        render_mode: int = 0,

        border_width: float = 0.05,

        miter_limit: float = 1,

        rotate: int = 0,

        morph: OptSeq = None,

        stroke_opacity: float = 1,

        fill_opacity: float = 1,

        oc: int = 0,

    ) -> int:

    

        # ensure 'text' is a list of strings, worth dealing with

        if not bool(buffer):

            return 0

    

        if type(buffer) not in (list, tuple):

            text = buffer.splitlines()

        else:

            text = buffer

    

        if not len(text) > 0:

            return 0

    

        point = pymupdf.Point(point)

        try:

            maxcode = max([ord(c) for c in " ".join(text)])

        except Exception:

            pymupdf.exception_info()

            return 0

    

        # ensure valid 'fontname'

        fname = fontname

        if fname.startswith("/"):

            fname = fname[1:]

    

        xref = self.page.insert_font(

            fontname=fname, fontfile=fontfile, encoding=encoding, set_simple=set_simple

        )

        fontinfo = pymupdf.CheckFontInfo(self.doc, xref)

    

        fontdict = fontinfo[1]

        ordering = fontdict["ordering"]

        simple = fontdict["simple"]

        bfname = fontdict["name"]

        ascender = fontdict["ascender"]

        descender = fontdict["descender"]

        if lineheight:

            lheight = fontsize * lineheight

        elif ascender - descender <= 1:

            lheight = fontsize * 1.2

        else:

            lheight = fontsize * (ascender - descender)

    

        if maxcode > 255:

            glyphs = self.doc.get_char_widths(xref, maxcode + 1)

        else:

            glyphs = fontdict["glyphs"]

    

        tab = []

        for t in text:

            if simple and bfname not in ("Symbol", "ZapfDingbats"):

                g = None

            else:

                g = glyphs

            tab.append(pymupdf.getTJstr(t, g, simple, ordering))

        text = tab

    

        color_str = pymupdf.ColorCode(color, "c")

        fill_str = pymupdf.ColorCode(fill, "f")

        if not fill and render_mode == 0:  # ensure fill color when 0 Tr

            fill = color

            fill_str = pymupdf.ColorCode(color, "f")

    

        morphing = pymupdf.CheckMorph(morph)

        rot = rotate

        if rot % 90 != 0:

>           raise ValueError("bad rotate value")

E           ValueError: bad rotate value



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3631: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 22.67s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -42,7 +42,7 @@
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
                 fontsize=18,
-                rotate=0,
+                rotate= -1,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: bad rotate value

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000223E6ACB620>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000223E3DE3170>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymupdf.utils.Shape object at 0x00000223E6B704D0>

point = Point(72.0, 72.0)

buffer = 'Intended for: unit-test-recipient\nDo not disclose'



    def insert_text(

        self,

        point: point_like,

        buffer: typing.Union[str, list],

        *,

        fontsize: float = 11,

        lineheight: OptFloat = None,

        fontname: str = "helv",

        fontfile: OptStr = None,

        set_simple: bool = 0,

        encoding: int = 0,

        color: OptSeq = None,

        fill: OptSeq = None,

        render_mode: int = 0,

        border_width: float = 0.05,

        miter_limit: float = 1,

        rotate: int = 0,

        morph: OptSeq = None,

        stroke_opacity: float = 1,

        fill_opacity: float = 1,

        oc: int = 0,

    ) -> int:

    

        # ensure 'text' is a list of strings, worth dealing with

        if not bool(buffer):

            return 0

    

        if type(buffer) not in (list, tuple):

            text = buffer.splitlines()

        else:

            text = buffer

    

        if not len(text) > 0:

            return 0

    

        point = pymupdf.Point(point)

        try:

            maxcode = max([ord(c) for c in " ".join(text)])

        except Exception:

            pymupdf.exception_info()

            return 0

    

        # ensure valid 'fontname'

        fname = fontname

        if fname.startswith("/"):

            fname = fname[1:]

    

        xref = self.page.insert_font(

            fontname=fname, fontfile=fontfile, encoding=encoding, set_simple=set_simple

        )

        fontinfo = pymupdf.CheckFontInfo(self.doc, xref)

    

        fontdict = fontinfo[1]

        ordering = fontdict["ordering"]

        simple = fontdict["simple"]

        bfname = fontdict["name"]

        ascender = fontdict["ascender"]

        descender = fontdict["descender"]

        if lineheight:

            lheight = fontsize * lineheight

        elif ascender - descender <= 1:

            lheight = fontsize * 1.2

        else:

            lheight = fontsize * (ascender - descender)

    

        if maxcode > 255:

            glyphs = self.doc.get_char_widths(xref, maxcode + 1)

        else:

            glyphs = fontdict["glyphs"]

    

        tab = []

        for t in text:

            if simple and bfname not in ("Symbol", "ZapfDingbats"):

                g = None

            else:

                g = glyphs

            tab.append(pymupdf.getTJstr(t, g, simple, ordering))

        text = tab

    

        color_str = pymupdf.ColorCode(color, "c")

        fill_str = pymupdf.ColorCode(fill, "f")

        if not fill and render_mode == 0:  # ensure fill color when 0 Tr

            fill = color

            fill_str = pymupdf.ColorCode(color, "f")

    

        morphing = pymupdf.CheckMorph(morph)

        rot = rotate

        if rot % 90 != 0:

>           raise ValueError("bad rotate value")

E           ValueError: bad rotate value



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3631: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000223E6ACBB90>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000223E3DE3170>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2038/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <pymupdf.utils.Shape object at 0x00000223E6B60EF0>

point = Point(72.0, 72.0)

buffer = 'Intended for: unit-test-recipient\nDo not disclose'



    def insert_text(

        self,

        point: point_like,

        buffer: typing.Union[str, list],

        *,

        fontsize: float = 11,

        lineheight: OptFloat = None,

        fontname: str = "helv",

        fontfile: OptStr = None,

        set_simple: bool = 0,

        encoding: int = 0,

        color: OptSeq = None,

        fill: OptSeq = None,

        render_mode: int = 0,

        border_width: float = 0.05,

        miter_limit: float = 1,

        rotate: int = 0,

        morph: OptSeq = None,

        stroke_opacity: float = 1,

        fill_opacity: float = 1,

        oc: int = 0,

    ) -> int:

    

        # ensure 'text' is a list of strings, worth dealing with

        if not bool(buffer):

            return 0

    

        if type(buffer) not in (list, tuple):

            text = buffer.splitlines()

        else:

            text = buffer

    

        if not len(text) > 0:

            return 0

    

        point = pymupdf.Point(point)

        try:

            maxcode = max([ord(c) for c in " ".join(text)])

        except Exception:

            pymupdf.exception_info()

            return 0

    

        # ensure valid 'fontname'

        fname = fontname

        if fname.startswith("/"):

            fname = fname[1:]

    

        xref = self.page.insert_font(

            fontname=fname, fontfile=fontfile, encoding=encoding, set_simple=set_simple

        )

        fontinfo = pymupdf.CheckFontInfo(self.doc, xref)

    

        fontdict = fontinfo[1]

        ordering = fontdict["ordering"]

        simple = fontdict["simple"]

        bfname = fontdict["name"]

        ascender = fontdict["ascender"]

        descender = fontdict["descender"]

        if lineheight:

            lheight = fontsize * lineheight

        elif ascender - descender <= 1:

            lheight = fontsize * 1.2

        else:

            lheight = fontsize * (ascender - descender)

    

        if maxcode > 255:

            glyphs = self.doc.get_char_widths(xref, maxcode + 1)

        else:

            glyphs = fontdict["glyphs"]

    

        tab = []

        for t in text:

            if simple and bfname not in ("Symbol", "ZapfDingbats"):

                g = None

            else:

                g = glyphs

            tab.append(pymupdf.getTJstr(t, g, simple, ordering))

        text = tab

    

        color_str = pymupdf.ColorCode(color, "c")

        fill_str = pymupdf.ColorCode(fill, "f")

        if not fill and render_mode == 0:  # ensure fill color when 0 Tr

            fill = color

            fill_str = pymupdf.ColorCode(color, "f")

    

        morphing = pymupdf.CheckMorph(morph)

        rot = rotate

        if rot % 90 != 0:

>           raise ValueError("bad rotate value")

E           ValueError: bad rotate value



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3631: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.88s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=( 1.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000025794FC7740>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000025793FE4050>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (1.6, 0.6, 0.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000025794FC7CB0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000025793FE4050>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-285/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (1.6, 0.6, 0.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 21.95s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=( -0.4, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.FFFFFFF.FFF.......F..F...................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T111855645363Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T111856574082Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022E18607680>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022E17518FE0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (-0.4, 0.6, 0.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022E18607BF0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022E17518FE0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-291/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (-0.4, 0.6, 0.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

12 failed, 30 passed, 23 warnings in 21.87s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=(0.6, 1.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000160824477D0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000160812CE510>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0.6, 1.6, 0.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000016082447D40>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000160812CE510>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1339/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0.6, 1.6, 0.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 22.56s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=(0.6, -0.4, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019D3B5CB380>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000019D389AAB40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0.6, -0.4, 0.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019D3B5CB8F0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000019D389AAB40>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2230/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0.6, -0.4, 0.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 22.01s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=(0.6, 0.6, 1.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002098644B4D0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002098535CE90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0.6, 0.6, 1.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002098644BA40>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002098535CE90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-602/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0.6, 0.6, 1.6)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 22.03s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -43,7 +43,7 @@
                 visible_watermark,
                 fontsize=18,
                 rotate=0,
-                fill=(0.6, 0.6, 0.6),  # fill color (gray)
+                fill=(0.6, 0.6, -0.4),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000216CF4AB680>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000216CC9E7140>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0.6, 0.6, -0.4)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000216CF4ABBF0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000216CC9E7140>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2391/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3623: in insert_text

    fill_str = pymupdf.ColorCode(fill, "f")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0.6, 0.6, -0.4)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 22.44s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=( 1, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=( -1, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BA532AB200>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001BA521BCC50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3622: in insert_text

    color_str = pymupdf.ColorCode(color, "c")

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (-1, 0, 0)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BA532AB770>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001BA521BCC50>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1705/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3622: in insert_text

    color_str = pymupdf.ColorCode(color, "c")

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (-1, 0, 0)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 21.95s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=(0, 1, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=(0, -1, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: need 1, 3 or 4 color components in range 0 to 1

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000021C19FB7650>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000021C16D2E150>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3622: in insert_text

    color_str = pymupdf.ColorCode(color, "c")

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0, -1, 0)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000021C19FB7BC0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000021C16D2E150>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2174/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3622: in insert_text

    color_str = pymupdf.ColorCode(color, "c")

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0, -1, 0)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 21.97s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=(0, 0, 1),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -44,7 +44,7 @@
                 fontsize=18,
                 rotate=0,
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
-                color=(0, 0, 0),
+                color=(0, 0, -1),
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
.FFF.F.F.FFF.......F..F...................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T233332275062Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T233333101741Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B6022575C0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B67F702F00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3622: in insert_text

    color_str = pymupdf.ColorCode(color, "c")

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0, 0, -1)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B602257B30>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B67F702F00>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2282/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

structural_and_overlay_watermark.py:41: in visible_watermark

    page.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:2351: in insert_text

    rc = img.insert_text(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\utils.py:3622: in insert_text

    color_str = pymupdf.ColorCode(color, "c")

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17552: in ColorCode

    CheckColor(c)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



c = (0, 0, -1)



    def CheckColor(c: OptSeq):

        if c:

            if (

                type(c) not in (list, tuple)

                or len(c) not in (1, 3, 4)

                or min(c) < 0

                or max(c) > 1

            ):

>               raise ValueError("need 1, 3 or 4 color components in range 0 to 1")

E               ValueError: need 1, 3 or 4 color components in range 0 to 1



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pymupdf\__init__.py:17472: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

10 failed, 32 passed, 23 warnings in 21.44s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -46,7 +46,7 @@
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
-                render_mode=2,  # stroke + fill
+                render_mode= 3,  # stroke + fill
                 fill_opacity=0.5,
                 stroke_opacity=0.5,
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -46,7 +46,7 @@
                 fill=(0.6, 0.6, 0.6),  # fill color (gray)
                 color=(0, 0, 0),
                 overlay=True,
-                render_mode=2,  # stroke + fill
+                render_mode= 1,  # stroke + fill
                 fill_opacity=0.5,
                 stroke_opacity=0.5,
             )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -47,7 +47,7 @@
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
-                fill_opacity=0.5,
+                fill_opacity= 1.5,
                 stroke_opacity=0.5,
             )
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -47,7 +47,7 @@
                 color=(0, 0, 0),
                 overlay=True,
                 render_mode=2,  # stroke + fill
-                fill_opacity=0.5,
+                fill_opacity= -0.5,
                 stroke_opacity=0.5,
             )
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.92s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -48,7 +48,7 @@
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
-                stroke_opacity=0.5,
+                stroke_opacity= 1.5,
             )
 
         output_stream = BytesIO()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -48,7 +48,7 @@
                 overlay=True,
                 render_mode=2,  # stroke + fill
                 fill_opacity=0.5,
-                stroke_opacity=0.5,
+                stroke_opacity= -0.5,
             )
 
         output_stream = BytesIO()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -54,7 +54,7 @@
         output_stream = BytesIO()
         doc.save(output_stream)
         doc.close()
-        output_stream.seek(0)
+        output_stream.seek( 1)
         return output_stream.read()
 
     @staticmethod
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -54,7 +54,7 @@
         output_stream = BytesIO()
         doc.save(output_stream)
         doc.close()
-        output_stream.seek(0)
+        output_stream.seek( -1)
         return output_stream.read()
 
     @staticmethod
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: negative seek value -1

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000024A49A87800>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000024A4890F710>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf_bytes = b'%PDF-1.5\n%\xc3\xa4\xc3\xbc\xc3\xb6\xc3\x9f\n2 0 obj\n<</Length 3 0 R/Filter/FlateDecode>>\nstream\nx\x9c\xadZK\x8f\...>\n<131B47C29D42EE0998F8FBFA411127C3> ]\n/DocChecksum /EC879B7D25D058FE1A4352DCEF098D78\n>>\nstartxref\n37827\n%%EOF\n'

visible_watermark = 'Intended for: unit-test-recipient\nDo not disclose'



    @staticmethod

    def visible_watermark(pdf_bytes: bytes, visible_watermark: str):

        """

        Applies a visible watermark to each page of a PDF (in-memory).

        Returns the updated PDF as bytes.

        """

        input_stream = BytesIO(pdf_bytes)

        doc = fitz.open(stream=input_stream, filetype="pdf")

    

        for page in doc:

            page.insert_text(

                (72, 72),  # Top-left corner (x, y)

                visible_watermark,

                fontsize=18,

                rotate=0,

                fill=(0.6, 0.6, 0.6),  # fill color (gray)

                color=(0, 0, 0),

                overlay=True,

                render_mode=2,  # stroke + fill

                fill_opacity=0.5,

                stroke_opacity=0.5,

            )

    

        output_stream = BytesIO()

        doc.save(output_stream)

        doc.close()

>       output_stream.seek( -1)

E       ValueError: negative seek value -1



structural_and_overlay_watermark.py:57: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000024A49A87D70>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000024A4890F710>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-495/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:101: in add_watermark

    visibly_watermarked = self.visible_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf_bytes = b'%PDF-1.5\n%\xc3\xa4\xc3\xbc\xc3\xb6\xc3\x9f\n2 0 obj\n<</Length 3 0 R/Filter/FlateDecode>>\nstream\nx\x9c\xadZK\x8f\...>\n<131B47C29D42EE0998F8FBFA411127C3> ]\n/DocChecksum /EC879B7D25D058FE1A4352DCEF098D78\n>>\nstartxref\n37827\n%%EOF\n'

visible_watermark = 'Intended for: unit-test-recipient\nDo not disclose'



    @staticmethod

    def visible_watermark(pdf_bytes: bytes, visible_watermark: str):

        """

        Applies a visible watermark to each page of a PDF (in-memory).

        Returns the updated PDF as bytes.

        """

        input_stream = BytesIO(pdf_bytes)

        doc = fitz.open(stream=input_stream, filetype="pdf")

    

        for page in doc:

            page.insert_text(

                (72, 72),  # Top-left corner (x, y)

                visible_watermark,

                fontsize=18,

                rotate=0,

                fill=(0.6, 0.6, 0.6),  # fill color (gray)

                color=(0, 0, 0),

                overlay=True,

                render_mode=2,  # stroke + fill

                fill_opacity=0.5,

                stroke_opacity=0.5,

            )

    

        output_stream = BytesIO()

        doc.save(output_stream)

        doc.close()

>       output_stream.seek( -1)

E       ValueError: negative seek value -1



structural_and_overlay_watermark.py:57: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -81,7 +81,7 @@
 
         output_stream = BytesIO()
         writer.write(output_stream)
-        output_stream.seek(0)
+        output_stream.seek( 1)
         return output_stream.read()
 
     def add_watermark(
...................F..F...................                               [100%]

================================== FAILURES ===================================

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022DBE527890>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022DBD44D0A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

        out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )

        assert isinstance(out_bytes, bytes | bytearray), (  # nosec B101

            f"{method_name}: add_watermark must return bytes"

        )

        assert len(out_bytes) >= len(original), (  # nosec B101

            f"{method_name}: watermarked bytes should not be smaller than input"

        )

>       assert out_bytes.startswith(b"%PDF-"), (  # nosec B101

            f"{method_name}: output should still look like a PDF"

        )

E       AssertionError: overlay-watermark: output should still look like a PDF

E       assert False

E        +  where False = <built-in method startswith of bytes object at 0x0000022DBCA21380>(b'%PDF-')

E        +    where <built-in method startswith of bytes object at 0x0000022DBCA21380> = b'PDF-1.5\n%\xe2\xe3\xcf\xd3\n1 0 obj\n<<\n/Type /Pages\n/Count 2\n/Kids [ 4 0 R 20 0 R ]\n>>\nendobj\n2 0 obj\n<<\n/P...00038457 00000 n \n0000038510 00000 n \ntrailer\n<<\n/Size 25\n/Root 3 0 R\n/Info 2 0 R\n>>\nstartxref\n38754\n%%EOF\n'.startswith



..\test\test_watermarking_all_methods.py:100: AssertionError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022DBE527E00>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000022DBD44D0A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1013/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:144: in read_secret

    pdf_bytes = load_pdf_bytes(pdf)

                ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



src = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1013/test_read_secret_roundtrip_ove0/overlay-watermark_watermarked.pdf')



    def load_pdf_bytes(src: PdfSource) -> bytes:

        """Normalize a :class:`PdfSource` into raw ``bytes``.

    

        Parameters

        ----------

        src:

            The PDF input. Can be raw bytes, an open binary file handle,

            or a filesystem path (``str``/``PathLike``).

    

        Returns

        -------

        bytes

            The full contents of the PDF as a byte string.

    

        Raises

        ------

        FileNotFoundError

            If ``src`` is a path that does not exist.

        ValueError

            If the resolved bytes do not appear to be a PDF file.

        """

        if isinstance(src, bytes | bytearray):

            data = bytes(src)

        elif isinstance(src, str | os.PathLike):

            with open(os.fspath(src), "rb") as fh:

                data = fh.read()

        elif hasattr(src, "read"):

            # Treat as a binary file-like (IO[bytes])

            data = src.read()  # type: ignore[attr-defined]

        else:

            raise TypeError("Unsupported PdfSource; expected bytes, path, or binary IO")

    

        if not is_pdf_bytes(data):

>           raise ValueError("Input does not look like a valid PDF (missing %PDF header)")

E           ValueError: Input does not look like a valid PDF (missing %PDF header)



watermarking_method.py:110: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

2 failed, 40 passed, 23 warnings in 20.72s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -81,7 +81,7 @@
 
         output_stream = BytesIO()
         writer.write(output_stream)
-        output_stream.seek(0)
+        output_stream.seek( -1)
         return output_stream.read()
 
     def add_watermark(
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: negative seek value -1

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002537DE2B530>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002537CD4CF20>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:116: in add_watermark

    fully_watermarked = self.structural_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf_bytes = b'%PDF-1.5\n%\xc2\xb5\xc2\xb6\n\n1 0 obj\n<</Type/Page/Parent 7 0 R/Resources 19 0 R/MediaBox[0 0 595.30398 841.8898]/... 0 R/Root 20 0 R/ID[<131B47C29D42EE0998F8FBFA411127C3><A7627D37068731C5AF407E6D213A7DD6>]>>\nstartxref\n38616\n%%EOF\n'

hidden_data = 'gAAAAABo8npn2PLU6xZMV37RLIYxg9xgEIdwMk-gavHcmxQFR5PNvdQD4p_AfeueLCigRMepcb_lfqQV_jhOd7JLYkGYrji9bAr-IullvvatZB5xjYxWOg8='



    @staticmethod

    def structural_watermark(pdf_bytes: bytes, hidden_data: str) -> bytes:

        """

        Adds a hidden structural watermark to the PDF (in-memory).

        Embeds hidden data in each page's dictionary.

        Returns the updated PDF as bytes.

        """

        input_stream = BytesIO(pdf_bytes)

        reader = PdfReader(input_stream)

        writer = PdfWriter()

    

        # Creating an incospicuous location to hide the watermark.

        # Adding in /PieceInfo (app. specific metadata)

        # Obfuscated name makes it less obvious than "/Watermark"

        obfuscated_key = NameObject("/XObjD5fA2e1")

    

        for page in reader.pages:

            piece_info = page.get("/PieceInfo") or DictionaryObject()

            piece_info.update({obfuscated_key: create_string_object(hidden_data)})

            page[NameObject("/PieceInfo")] = piece_info

            writer.add_page(page)

    

        output_stream = BytesIO()

        writer.write(output_stream)

>       output_stream.seek( -1)

E       ValueError: negative seek value -1



structural_and_overlay_watermark.py:84: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002537DE2BAA0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002537CD4CF20>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1266/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:116: in add_watermark

    fully_watermarked = self.structural_watermark(

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



pdf_bytes = b'%PDF-1.5\n%\xc2\xb5\xc2\xb6\n\n1 0 obj\n<</Type/Page/Parent 7 0 R/Resources 19 0 R/MediaBox[0 0 595.30398 841.8898]/... 0 R/Root 20 0 R/ID[<131B47C29D42EE0998F8FBFA411127C3><6E775B2F6F34C49C0A2CAFEF185E1E71>]>>\nstartxref\n38616\n%%EOF\n'

hidden_data = 'gAAAAABo8npnRHmaatS77gs39qVwsOwwqtEd1wuKQ5WDr7sQkgarr8J_i_yYdu8xNJEtb-LRIyWu-BbXYulpaNIVTC5jaGXENTZgv4NwIOkU2YdPrVMIpBU='



    @staticmethod

    def structural_watermark(pdf_bytes: bytes, hidden_data: str) -> bytes:

        """

        Adds a hidden structural watermark to the PDF (in-memory).

        Embeds hidden data in each page's dictionary.

        Returns the updated PDF as bytes.

        """

        input_stream = BytesIO(pdf_bytes)

        reader = PdfReader(input_stream)

        writer = PdfWriter()

    

        # Creating an incospicuous location to hide the watermark.

        # Adding in /PieceInfo (app. specific metadata)

        # Obfuscated name makes it less obvious than "/Watermark"

        obfuscated_key = NameObject("/XObjD5fA2e1")

    

        for page in reader.pages:

            piece_info = page.get("/PieceInfo") or DictionaryObject()

            piece_info.update({obfuscated_key: create_string_object(hidden_data)})

            page[NameObject("/PieceInfo")] = piece_info

            writer.add_page(page)

    

        output_stream = BytesIO()

        writer.write(output_stream)

>       output_stream.seek( -1)

E       ValueError: negative seek value -1



structural_and_overlay_watermark.py:84: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -133,7 +133,7 @@
         """
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,
+            length= 33,
             salt=b"try_and_break_me",
             iterations=200_000,
             backend=default_backend(),
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Fernet key must be 32 url-safe base64-encoded bytes.

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002C4BA19B650>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002C4B92340B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:114: in add_watermark

    fernet = Fernet(derived_key)

             ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <cryptography.fernet.Fernet object at 0x000002C4BA449AC0>

key = b'(i\xaa\xf9Cn\xb4\xb0~\x04\x1c\x94L\xfeV\xf8\x05X\x18\x81\x133\x1c\xec\xbd\x06QzF\x839\xd0@'

backend = None



    def __init__(

        self,

        key: bytes | str,

        backend: typing.Any = None,

    ) -> None:

        try:

            key = base64.urlsafe_b64decode(key)

        except binascii.Error as exc:

            raise ValueError(

                "Fernet key must be 32 url-safe base64-encoded bytes."

            ) from exc

        if len(key) != 32:

>           raise ValueError(

                "Fernet key must be 32 url-safe base64-encoded bytes."

            )

E           ValueError: Fernet key must be 32 url-safe base64-encoded bytes.



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cryptography\fernet.py:41: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002C4BA19BBC0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002C4B92340B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2457/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:114: in add_watermark

    fernet = Fernet(derived_key)

             ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <cryptography.fernet.Fernet object at 0x000002C4BA6229F0>

key = b'(i\xaa\xf9Cn\xb4\xb0~\x04\x1c\x94L\xfeV\xf8\x05X\x18\x81\x133\x1c\xec\xbd\x06QzF\x839\xd0@'

backend = None



    def __init__(

        self,

        key: bytes | str,

        backend: typing.Any = None,

    ) -> None:

        try:

            key = base64.urlsafe_b64decode(key)

        except binascii.Error as exc:

            raise ValueError(

                "Fernet key must be 32 url-safe base64-encoded bytes."

            ) from exc

        if len(key) != 32:

>           raise ValueError(

                "Fernet key must be 32 url-safe base64-encoded bytes."

            )

E           ValueError: Fernet key must be 32 url-safe base64-encoded bytes.



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cryptography\fernet.py:41: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -133,7 +133,7 @@
         """
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,
+            length= 31,
             salt=b"try_and_break_me",
             iterations=200_000,
             backend=default_backend(),
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: Fernet key must be 32 url-safe base64-encoded bytes.

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001FAD8647680>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001FAD75793D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:114: in add_watermark

    fernet = Fernet(derived_key)

             ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <cryptography.fernet.Fernet object at 0x000001FAD8ADE780>

key = b'(i\xaa\xf9Cn\xb4\xb0~\x04\x1c\x94L\xfeV\xf8\x05X\x18\x81\x133\x1c\xec\xbd\x06QzF\x839'

backend = None



    def __init__(

        self,

        key: bytes | str,

        backend: typing.Any = None,

    ) -> None:

        try:

            key = base64.urlsafe_b64decode(key)

        except binascii.Error as exc:

            raise ValueError(

                "Fernet key must be 32 url-safe base64-encoded bytes."

            ) from exc

        if len(key) != 32:

>           raise ValueError(

                "Fernet key must be 32 url-safe base64-encoded bytes."

            )

E           ValueError: Fernet key must be 32 url-safe base64-encoded bytes.



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cryptography\fernet.py:41: ValueError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001FAD8647BF0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001FAD75793D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-536/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

structural_and_overlay_watermark.py:114: in add_watermark

    fernet = Fernet(derived_key)

             ^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <cryptography.fernet.Fernet object at 0x000001FAD8647380>

key = b'(i\xaa\xf9Cn\xb4\xb0~\x04\x1c\x94L\xfeV\xf8\x05X\x18\x81\x133\x1c\xec\xbd\x06QzF\x839'

backend = None



    def __init__(

        self,

        key: bytes | str,

        backend: typing.Any = None,

    ) -> None:

        try:

            key = base64.urlsafe_b64decode(key)

        except binascii.Error as exc:

            raise ValueError(

                "Fernet key must be 32 url-safe base64-encoded bytes."

            ) from exc

        if len(key) != 32:

>           raise ValueError(

                "Fernet key must be 32 url-safe base64-encoded bytes."

            )

E           ValueError: Fernet key must be 32 url-safe base64-encoded bytes.



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cryptography\fernet.py:41: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -135,7 +135,7 @@
             algorithm=hashes.SHA256(),
             length=32,
             salt=b"try_and_break_me",
-            iterations=200_000,
+            iterations= 200001,
             backend=default_backend(),
         )
         return base64.urlsafe_b64encode(kdf.derive(password.encode()))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -135,7 +135,7 @@
             algorithm=hashes.SHA256(),
             length=32,
             salt=b"try_and_break_me",
-            iterations=200_000,
+            iterations= 199999,
             backend=default_backend(),
         )
         return base64.urlsafe_b64encode(kdf.derive(password.encode()))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -166,5 +166,5 @@
             else:
                 extracted_data.append(None)  # No watermark found on this page
 
-        return str(extracted_data[0])
+        return str(extracted_data[ 1])
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -166,5 +166,5 @@
             else:
                 extracted_data.append(None)  # No watermark found on this page
 
-        return str(extracted_data[0])
+        return str(extracted_data[ -1])
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -23,8 +23,6 @@
 
 class StructuralOverlay(WatermarkingMethod):
     name = "overlay-watermark"
-
-    @staticmethod
     def get_usage() -> str:
         return "Method that overlays a visible watermark."
 
.FFF.F.FFFFF.............................F                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193211778734Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

>       resp = client.get("/api/get-watermarking-methods")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:312: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.get("/api/get-watermarking-methods")

    def get_watermarking_methods():

        methods = []

    

        for m in WMUtils.METHODS:

            methods.append(

>               {"name": m, "description": WMUtils.get_method(m).get_usage()}

                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

            )

E           TypeError: StructuralOverlay.get_usage() takes 0 positional arguments but 1 was given



server.py:1137: TypeError

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T193212749741Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_________ TestWatermarkingUtils.test_method_get_usage_returns_string __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x00000181D7AF1F70>



    def test_method_get_usage_returns_string(self):

        """Test that all methods return string from get_usage."""

        for _name, method in WMUtils.METHODS.items():

>           usage = method.get_usage()

                    ^^^^^^^^^^^^^^^^^^

E           TypeError: StructuralOverlay.get_usage() takes 0 positional arguments but 1 was given



..\test\test_watermarking_utilities.py:258: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - TypeError: ...

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_method_get_usage_returns_string

10 failed, 32 passed, 23 warnings in 20.62s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -27,8 +27,6 @@
     @staticmethod
     def get_usage() -> str:
         return "Method that overlays a visible watermark."
-
-    @staticmethod
     def visible_watermark(pdf_bytes: bytes, visible_watermark: str):
         """
         Applies a visible watermark to each page of a PDF (in-memory).
.FFF.F.F.FFF.......F..F...................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T231047712547Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T231048569773Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000021748F677D0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000021746DB9D90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000021746DB9D90>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

>       visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

E       TypeError: StructuralOverlay.visible_watermark() takes 2 positional arguments but 3 were given



structural_and_overlay_watermark.py:99: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000021748F67D40>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000021746DB9D90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2224/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000021746DB9D90>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

>       visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

E       TypeError: StructuralOverlay.visible_watermark() takes 2 positional arguments but 3 were given



structural_and_overlay_watermark.py:99: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

10 failed, 32 passed, 23 warnings in 20.08s

operator: core/RemoveDecorator, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -56,8 +56,6 @@
         doc.close()
         output_stream.seek(0)
         return output_stream.read()
-
-    @staticmethod
     def structural_watermark(pdf_bytes: bytes, hidden_data: str) -> bytes:
         """
         Adds a hidden structural watermark to the PDF (in-memory).
.FFF.F.F.FFF.......F..F...................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T155041817351Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T155042670193Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000017183717740>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000017180BF3FB0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000017180BF3FB0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if not isinstance(key, str) or not key:

            raise ValueError("Key must be a non-empty string")

    

        # Add the "real" watermark by embedding the secret into

        # the PDF structure.

        # Encrypt the secret for extra security

        derived_key = self.derive_fernet_key(key)

        fernet = Fernet(derived_key)

        encrypted_secret = fernet.encrypt(secret.encode()).decode()

>       fully_watermarked = self.structural_watermark(

            visibly_watermarked, encrypted_secret

        )

E       TypeError: StructuralOverlay.structural_watermark() takes 2 positional arguments but 3 were given



structural_and_overlay_watermark.py:114: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000017183717CB0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000017180BF3FB0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1029/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000017180BF3FB0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if not isinstance(key, str) or not key:

            raise ValueError("Key must be a non-empty string")

    

        # Add the "real" watermark by embedding the secret into

        # the PDF structure.

        # Encrypt the secret for extra security

        derived_key = self.derive_fernet_key(key)

        fernet = Fernet(derived_key)

        encrypted_secret = fernet.encrypt(secret.encode()).decode()

>       fully_watermarked = self.structural_watermark(

            visibly_watermarked, encrypted_secret

        )

E       TypeError: StructuralOverlay.structural_watermark() takes 2 positional arguments but 3 were given



structural_and_overlay_watermark.py:114: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

10 failed, 32 passed, 23 warnings in 20.28s

operator: core/RemoveDecorator, occurrence: 3
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -125,8 +125,6 @@
         position: str | None = None,
     ) -> bool:
         return True
-
-    @staticmethod
     def derive_fernet_key(password: str) -> bytes:
         """
         Derive a Fernet-compatible key from a string password using PBKDF2.
.........F.........F..F...................                               [100%]

================================== FAILURES ===================================

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

        assert resp.status_code == 201

        assert resp.is_json

        #check types

        assert isinstance(data.get("id"), int)

        assert isinstance(data.get("documentid"), int)

        assert isinstance(data.get("link"), str)

        assert isinstance(data.get("intended_for"), str)

        assert isinstance(data.get("method"), str)

        assert isinstance(data.get("position"), str)

        assert isinstance(data.get("filename"), str)

        assert isinstance(data.get("size"), int)

        #check values

        assert data.get("documentid") == parameters["id"]

        assert data.get("intended_for") == parameters["intended_for"]

        assert data.get("method") == parameters["method"]

        assert data.get("position") == parameters["position"]

    

        #Tests with wrong parameters

        #Test with exact same call: should return database insertion error (Non unique entry)

        resp = client.post("/api/create-watermark", json=parameters)

        assert resp.status_code == 503

        #Non existant method

        resp = client.post("/api/create-watermark", json={"method": "watermarkmethod", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Non existant document

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 8})

        assert resp.status_code == 404

        #Missing id

        resp = client.post("/api/create-watermark", json={"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse"})

        assert resp.status_code == 400

        #Missing method

        resp = client.post("/api/create-watermark", json={"position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1})

        assert resp.status_code == 400

        #Missing position: no issue if method ignores

        # (NB: must change intended_for or secret etc! Else integrity error.)

        resp = client.post("/api/create-watermark", json={"method": "overlay-watermark", "key": "key",

                        "secret": "secret", "intended_for":"John", "id": 1})

>       assert resp.status_code == 201

E       assert 500 == 201

E        +  where 500 = <WrapperTestResponse streamed [500 INTERNAL SERVER ERROR]>.status_code



..\test\test_api.py:378: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1097 Integrity error during version insert for document 1: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b' for key 'uq_Versions_link'")

[SQL: 

                        INSERT INTO Versions (documentid, link, intended_for,

                                            secret, method, position, path)

                        VALUES (%(documentid)s, %(link)s, %(intended_for)s, %(secret)s,

                               %(method)s, %(position)s, %(path)s)

                    ]

[parameters: {'documentid': 1, 'link': 'b844de8060c148285cdf347927f723d01bd81b35ea64b58b7494157eba1a274b', 'intended_for': 'Mickey Mouse', 'secret': 'secret', 'method': 'robust-xmp', 'position': 'metadata-only', 'path': 'C:\\Users\\franc\\Documents\\GitHub\\softsec-tatou\\server\\src\\storage\\files\\username\\watermarks\\My File__Mickey_Mouse.pdf'}]

(Background on this error at: https://sqlalche.me/e/20/gkpj)

ERROR    server:server.py:1007 Watermark applicability check failed for document 1: "Unknown watermarking method: 'watermarkmethod'. Known: ['overlay-watermark', 'robust-xmp', 'signed-annots']"

WARNING  server:server.py:972 Document not found or access denied for watermarking id=8

WARNING  server:server.py:934 Missing document id in request

WARNING  server:server.py:948 Missing required fields for watermarking: {'id': 1, 'intended_for': 'Mickey Mouse', 'key': 'key', 'position': 'metadata-only', 'secret': 'secret'}

ERROR    server:server.py:1034 Watermarking failed for document 1 using method overlay-watermark: StructuralOverlay.derive_fernet_key() takes 1 positional argument but 2 were given

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B3224EB740>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B3215840E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B3215840E0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if not isinstance(key, str) or not key:

            raise ValueError("Key must be a non-empty string")

    

        # Add the "real" watermark by embedding the secret into

        # the PDF structure.

        # Encrypt the secret for extra security

>       derived_key = self.derive_fernet_key(key)

                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: StructuralOverlay.derive_fernet_key() takes 1 positional argument but 2 were given



structural_and_overlay_watermark.py:113: TypeError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B3224EBCB0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B3215840E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1887/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x000001B3215840E0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        data = load_pdf_bytes(pdf)

        # Add a visible watermark. This might confuse the attackers,

        # suggesting that the only watermark is the visible watermark.

        # It also works as a deterrent against document diffusion.

        if not intended_for:

            raise ValueError("Missing recipient. (intended_for)")

        visibly_watermarked = self.visible_watermark(

            data, "Intended for: " + intended_for + "\nDo not disclose"

        )

    

        if not secret:

            raise ValueError("Secret must be a non-empty string")

        if not isinstance(key, str) or not key:

            raise ValueError("Key must be a non-empty string")

    

        # Add the "real" watermark by embedding the secret into

        # the PDF structure.

        # Encrypt the secret for extra security

>       derived_key = self.derive_fernet_key(key)

                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       TypeError: StructuralOverlay.derive_fernet_key() takes 1 positional argument but 2 were given



structural_and_overlay_watermark.py:113: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_watermark_route - assert 500 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

3 failed, 39 passed, 23 warnings in 20.58s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -37,7 +37,7 @@
         input_stream = BytesIO(pdf_bytes)
         doc = fitz.open(stream=input_stream, filetype="pdf")
 
-        for page in doc:
+        for page in []:
             page.insert_text(
                 (72, 72),  # Top-left corner (x, y)
                 visible_watermark,
...................F......................                               [100%]

================================== FAILURES ===================================

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026960ACB5C0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x000002695F9E8F80>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

        out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )

        assert isinstance(out_bytes, bytes | bytearray), (  # nosec B101

            f"{method_name}: add_watermark must return bytes"

        )

>       assert len(out_bytes) >= len(original), (  # nosec B101

            f"{method_name}: watermarked bytes should not be smaller than input"

        )

E       AssertionError: overlay-watermark: watermarked bytes should not be smaller than input

E       assert 38277 >= 38471

E        +  where 38277 = len(b'%PDF-1.5\n%\xe2\xe3\xcf\xd3\n1 0 obj\n<<\n/Type /Pages\n/Count 2\n/Kids [ 4 0 R 16 0 R ]\n>>\nendobj\n2 0 obj\n<<\n/...00037334 00000 n \n0000037674 00000 n \ntrailer\n<<\n/Size 18\n/Root 3 0 R\n/Info 2 0 R\n>>\nstartxref\n37838\n%%EOF\n')

E        +  and   38471 = len(b'%PDF-1.5\n%\xc3\xa4\xc3\xbc\xc3\xb6\xc3\x9f\n2 0 obj\n<</Length 3 0 R/Filter/FlateDecode>>\nstream\nx\x9c\xadZK\x8f\...>\n<131B47C29D42EE0998F8FBFA411127C3> ]\n/DocChecksum /EC879B7D25D058FE1A4352DCEF098D78\n>>\nstartxref\n37827\n%%EOF\n')



..\test\test_watermarking_all_methods.py:97: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

1 failed, 41 passed, 23 warnings in 20.94s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -73,7 +73,7 @@
         # Obfuscated name makes it less obvious than "/Watermark"
         obfuscated_key = NameObject("/XObjD5fA2e1")
 
-        for page in reader.pages:
+        for page in []:
             piece_info = page.get("/PieceInfo") or DictionaryObject()
             piece_info.update({obfuscated_key: create_string_object(hidden_data)})
             page[NameObject("/PieceInfo")] = piece_info
...................F..F...................                               [100%]

================================== FAILURES ===================================

_ TestAllWatermarkingMethods.test_add_watermark_and_shape[overlay-watermark] __



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001917672B440>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000019172830B90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

        out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )

        assert isinstance(out_bytes, bytes | bytearray), (  # nosec B101

            f"{method_name}: add_watermark must return bytes"

        )

>       assert len(out_bytes) >= len(original), (  # nosec B101

            f"{method_name}: watermarked bytes should not be smaller than input"

        )

E       AssertionError: overlay-watermark: watermarked bytes should not be smaller than input

E       assert 312 >= 38471

E        +  where 312 = len(b'%PDF-1.3\n%\xe2\xe3\xcf\xd3\n1 0 obj\n<<\n/Type /Pages\n/Count 0\n/Kids [ ]\n>>\nendobj\n2 0 obj\n<<\n/Producer (PyP...n0000000068 00000 n \n0000000108 00000 n \ntrailer\n<<\n/Size 4\n/Root 3 0 R\n/Info 2 0 R\n>>\nstartxref\n157\n%%EOF\n')

E        +  and   38471 = len(b'%PDF-1.5\n%\xc3\xa4\xc3\xbc\xc3\xb6\xc3\x9f\n2 0 obj\n<</Length 3 0 R/Filter/FlateDecode>>\nstream\nx\x9c\xadZK\x8f\...>\n<131B47C29D42EE0998F8FBFA411127C3> ]\n/DocChecksum /EC879B7D25D058FE1A4352DCEF098D78\n>>\nstartxref\n37827\n%%EOF\n')



..\test\test_watermarking_all_methods.py:97: AssertionError

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001917672B9B0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000019172830B90>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1091/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x0000019172830B90>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1091/test_read_secret_roundtrip_ove0/overlay-watermark_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        pdf_bytes = load_pdf_bytes(pdf)

        reader = PdfReader(BytesIO(pdf_bytes))

        extracted_data = []

    

        obfuscated_key = NameObject("/XObjD5fA2e1")

    

        for page in reader.pages:

            # Check for our custom structural watermark

            watermark_obj = page.get("/PieceInfo")

            if watermark_obj and obfuscated_key in watermark_obj:

                hidden = watermark_obj[obfuscated_key]

                # Extract string

                encrypted_str = str(hidden)

    

                # Try decryption, catch exceptions

                try:

                    derived_key = self.derive_fernet_key(key)

                    fernet = Fernet(derived_key)

                    decrypted = fernet.decrypt(encrypted_str.encode()).decode()

                    extracted_data.append(decrypted)

                except InvalidToken as e:

                    raise InvalidKeyError("Failed to decrypt watermark") from e

            else:

                extracted_data.append(None)  # No watermark found on this page

    

>       return str(extracted_data[0])

                   ^^^^^^^^^^^^^^^^^

E       IndexError: list index out of range



structural_and_overlay_watermark.py:169: IndexError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[overlay-watermark]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

2 failed, 40 passed, 23 warnings in 21.32s

operator: core/ZeroIterationForLoop, occurrence: 2
--- mutation diff ---
--- astructural_and_overlay_watermark.py
+++ bstructural_and_overlay_watermark.py
@@ -147,7 +147,7 @@
 
         obfuscated_key = NameObject("/XObjD5fA2e1")
 
-        for page in reader.pages:
+        for page in []:
             # Check for our custom structural watermark
             watermark_obj = page.get("/PieceInfo")
             if watermark_obj and obfuscated_key in watermark_obj:
..........F...........F...................                               [100%]

================================== FAILURES ===================================

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

            assert upload_resp.status_code == 201

            assert upload_resp_data.get("id") == 2

        #Test the route

    

        parameters = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password", "id": 2}

        parameters_no_id = {"method": "overlay-watermark", "position": "metadata-only", "key": "strong-password"}

        resp = client.post("/api/read-watermark", json=parameters)

        #resp = client.post("/api/read-watermark/2", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 400 == 201

E        +  where 400 = <WrapperTestResponse 52 bytes [400 BAD REQUEST]>.status_code



..\test\test_api.py:415: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:1226 Error when attempting to read watermark for document 2: list index out of range

__ TestAllWatermarkingMethods.test_read_secret_roundtrip[overlay-watermark] ___



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000262DB667CB0>

method_name = 'overlay-watermark'

impl = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000262D8B1FE60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1955/test_read_secret_roundtrip_ove0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <structural_and_overlay_watermark.StructuralOverlay object at 0x00000262D8B1FE60>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1955/test_read_secret_roundtrip_ove0/overlay-watermark_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        pdf_bytes = load_pdf_bytes(pdf)

        reader = PdfReader(BytesIO(pdf_bytes))

        extracted_data = []

    

        obfuscated_key = NameObject("/XObjD5fA2e1")

    

        for page in []:

            # Check for our custom structural watermark

            watermark_obj = page.get("/PieceInfo")

            if watermark_obj and obfuscated_key in watermark_obj:

                hidden = watermark_obj[obfuscated_key]

                # Extract string

                encrypted_str = str(hidden)

    

                # Try decryption, catch exceptions

                try:

                    derived_key = self.derive_fernet_key(key)

                    fernet = Fernet(derived_key)

                    decrypted = fernet.decrypt(encrypted_str.encode()).decode()

                    extracted_data.append(decrypted)

                except InvalidToken as e:

                    raise InvalidKeyError("Failed to decrypt watermark") from e

            else:

                extracted_data.append(None)  # No watermark found on this page

    

>       return str(extracted_data[0])

                   ^^^^^^^^^^^^^^^^^

E       IndexError: list index out of range



structural_and_overlay_watermark.py:169: IndexError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_read_watermark_route - assert 400 == 201

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[overlay-watermark]

2 failed, 40 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root + "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.45s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" + "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent + "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent + "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for +: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.81s

operator: core/ReplaceBinaryOperator_Div_Add, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent + "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root - "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.18s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" - "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent - "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent - "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for -: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.57s

operator: core/ReplaceBinaryOperator_Div_Sub, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent - "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root * "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" * "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T114731848161Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T114732737434Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent * "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent * "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): can't multiply sequence by non-int of type 'WindowsPath'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.61s

operator: core/ReplaceBinaryOperator_Div_Mul, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent * "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root // "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" // "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent // "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent // "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for //: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.53s

operator: core/ReplaceBinaryOperator_Div_FloorDiv, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent // "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root % "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" % "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent % "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T160419801143Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T160420668111Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent % "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
.FFFFFFF.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T145742389415Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T145742686850Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for %: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

13 failed, 29 passed, 9 warnings in 15.03s

operator: core/ReplaceBinaryOperator_Div_Mod, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent % "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.40s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root ** "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.73s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" ** "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent ** "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent ** "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ** or pow(): 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.63s

operator: core/ReplaceBinaryOperator_Div_Pow, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent ** "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root >> "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" >> "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.60s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent >> "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent >> "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for >>: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.77s

operator: core/ReplaceBinaryOperator_Div_RShift, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent >> "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T213321330882Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T213322218430Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.54s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root << "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.70s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" << "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent << "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent << "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for <<: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.56s

operator: core/ReplaceBinaryOperator_Div_LShift, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent << "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root | "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" | "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent | "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.25s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent | "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for |: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.95s

operator: core/ReplaceBinaryOperator_Div_BitOr, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent | "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.18s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root & "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" & "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent & "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent & "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
.FFFFF.F.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T235117087577Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T235117386088Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for &: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

12 failed, 30 passed, 9 warnings in 15.65s

operator: core/ReplaceBinaryOperator_Div_BitAnd, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent & "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root ^ "public-keys" / "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.38s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -49,7 +49,7 @@
         if public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
-            public_keys_dir = str(server_root / "public-keys" / "pki")
+            public_keys_dir = str(server_root / "public-keys" ^ "pki")
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -53,7 +53,7 @@
 
         if server_private_key is None:
             # Default to server_priv.asc in src directory
-            server_private_key = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key = str(Path(__file__).parent ^ "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
         server_public_key = str(Path(__file__).parent / "server_pub.asc")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -56,7 +56,7 @@
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
         # Server public key path (needed for IdentityManager)
-        server_public_key = str(Path(__file__).parent / "server_pub.asc")
+        server_public_key = str(Path(__file__).parent ^ "server_pub.asc")
 
         # Initialize RMAP components with correct API
         self.identity_manager = IdentityManager(
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

----------------------------- Captured log setup ------------------------------

WARNING  server:server.py:88 RMAP initialization failed (continuing): unsupported operand type(s) for ^: 'WindowsPath' and 'str'

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.54s

operator: core/ReplaceBinaryOperator_Div_BitXor, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -107,7 +107,7 @@
 
         try:
             # Load server private key for decryption
-            server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
+            server_private_key_path = str(Path(__file__).parent ^ "server_priv.asc")
             if not Path(server_private_key_path).exists():
                 return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str + None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.59s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str + None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 16.00s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] + None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.64s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str + None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.97s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] + None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.66s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str + None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
.FFF.F.F.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T115253058958Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T115253359111Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

11 failed, 31 passed, 9 warnings in 15.06s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str - None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.55s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str - None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
.FFF.F.F.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124011154309Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124011400735Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

11 failed, 31 passed, 9 warnings in 14.84s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] - None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.64s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str - None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.60s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] - None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.61s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str - None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.64s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str * None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.74s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str * None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.59s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] * None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.90s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str * None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.55s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] * None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
.FFFFFFF.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T003327648563Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251018T003327894513Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

13 failed, 29 passed, 9 warnings in 15.05s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str * None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.59s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str / None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.61s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str / None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.64s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] / None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.72s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str / None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 16.31s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] / None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.52s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str / None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.55s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str // None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
.FFFFFFF.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T110653182886Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T110653422014Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

13 failed, 29 passed, 9 warnings in 14.84s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str // None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.56s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] // None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.53s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str // None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.66s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] // None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.58s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str // None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.66s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str % None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.63s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str % None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.58s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] % None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.81s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str % None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.96s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] % None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.46s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str % None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.59s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str ** None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.51s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str ** None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.62s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] ** None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.73s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str ** None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.65s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] ** None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.54s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str ** None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
.FFF.F.F.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124810267651Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T124810611013Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

11 failed, 31 passed, 9 warnings in 15.05s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str >> None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.70s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str >> None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.46s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] >> None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.60s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str >> None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.65s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] >> None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.62s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str >> None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.49s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str << None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.60s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str << None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.69s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] << None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
.FFFFFFF.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144417107588Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T144417287197Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

13 failed, 29 passed, 9 warnings in 14.95s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str << None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.56s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] << None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.71s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str << None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.80s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str & None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.72s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str & None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
.FFFFFFF.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T104557653619Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T104557862788Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

13 failed, 29 passed, 9 warnings in 14.94s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] & None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.67s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str & None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
.FFFFFFF.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T230249536051Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T230249808155Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

13 failed, 29 passed, 9 warnings in 15.01s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] & None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.71s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str & None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.70s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -31,7 +31,7 @@
     def __init__(
         self,
         storage_dir: str,
-        public_keys_dir: str | None = None,
+        public_keys_dir: str ^ None = None,
         server_private_key: str | None = None,
     ):
         self.storage_dir = storage_dir
.FFF.F.F.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102611071007Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102611318224Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

11 failed, 31 passed, 9 warnings in 15.08s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -32,7 +32,7 @@
         self,
         storage_dir: str,
         public_keys_dir: str | None = None,
-        server_private_key: str | None = None,
+        server_private_key: str ^ None = None,
     ):
         self.storage_dir = storage_dir
         self.watermarked_pdfs: dict[
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.70s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -97,7 +97,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
+    def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] ^ None:
         """
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.72s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -187,7 +187,7 @@
         except Exception as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
-    def _find_identity_for_session(self, session_secret: str) -> str | None:
+    def _find_identity_for_session(self, session_secret: str) -> str ^ None:
         """
         Try to find the identity that corresponds to this session secret.
         This implements correlation between Message 1 and Message 2.
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.50s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -204,7 +204,7 @@
         # Default fallback - better than hardcoded "RMAP_CLIENT"
         return "Unknown_Group"
 
-    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] | None:
+    def get_watermarked_pdf_info(self, session_secret: str) -> dict[str, Any] ^ None:
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.67s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -208,7 +208,7 @@
         """Get watermarked PDF metadata for a session secret."""
         return self.watermarked_pdfs.get(session_secret)
 
-    def get_session_identity(self, session_secret: str) -> str | None:
+    def get_session_identity(self, session_secret: str) -> str ^ None:
         """Get the identity (group name) for a session secret."""
         return self.session_identities.get(session_secret)
 
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 405 == 200

E        +  where 405 = <WrapperTestResponse streamed [405 METHOD NOT ALLOWED]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



test/test_api.py::test_rmap_initiate

test/test_api.py::test_rmap_get_link

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 405 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 405 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 9 warnings in 15.74s

operator: core/ReplaceComparisonOperator_Lt_Eq, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) == 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceComparisonOperator_Lt_NotEq, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) != 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.63s

operator: core/ReplaceComparisonOperator_Lt_LtE, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) <= 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceComparisonOperator_Lt_Gt, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) > 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceComparisonOperator_Lt_GtE, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) >= 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150213416168Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T150214233313Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.30s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) == 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) != 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) < 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) <= 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T100544996160Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T100545945187Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.60s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) >= 32:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -46,7 +46,7 @@
         ] = {}  # Store identity for each nonce_client during handshake
 
         # Set up paths for keys
-        if public_keys_dir is None:
+        if public_keys_dir is not None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
             public_keys_dir = str(server_root / "public-keys" / "pki")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -51,7 +51,7 @@
             server_root = Path(__file__).parent.parent
             public_keys_dir = str(server_root / "public-keys" / "pki")
 
-        if server_private_key is None:
+        if server_private_key is not None:
             # Default to server_priv.asc in src directory
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceComparisonOperator_IsNot_Is, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -85,7 +85,7 @@
             if identity_data:
                 nonce_client = identity_data.get("nonceClient")
                 identity = identity_data.get("identity", "Unknown_Group")
-                if nonce_client is not None:
+                if nonce_client is None:
                     # Store identity for later correlation with session secret
                     self.pending_identities[nonce_client] = identity
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -102,7 +102,7 @@
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
         """
-        if not PGP_AVAILABLE:
+        if  PGP_AVAILABLE:
             return None
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -108,7 +108,7 @@
         try:
             # Load server private key for decryption
             server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
-            if not Path(server_private_key_path).exists():
+            if  Path(server_private_key_path).exists():
                 return None
 
             # Load the private key
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T134634431319Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T134635320571Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.54s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -117,7 +117,7 @@
             # Unlock the private key if it's protected
             if server_key.is_protected:
                 passphrase = os.getenv("PRIVKEY_PASSPHRASE", "")
-                if not passphrase:
+                if  passphrase:
                     return None
                 server_key.unlock(passphrase)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -46,7 +46,7 @@
         ] = {}  # Store identity for each nonce_client during handshake
 
         # Set up paths for keys
-        if public_keys_dir is None:
+        if not public_keys_dir is None:
             # Default to public-keys/pki directory relative to server root
             server_root = Path(__file__).parent.parent
             public_keys_dir = str(server_root / "public-keys" / "pki")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.42s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -51,7 +51,7 @@
             server_root = Path(__file__).parent.parent
             public_keys_dir = str(server_root / "public-keys" / "pki")
 
-        if server_private_key is None:
+        if not server_private_key is None:
             # Default to server_priv.asc in src directory
             server_private_key = str(Path(__file__).parent / "server_priv.asc")
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -77,7 +77,7 @@
         Returns: {"payload": "<base64(encrypted_response)>"} or {"error": "<reason>"}
         """
         try:
-            if "payload" not in incoming:
+            if not "payload" not in incoming:
                 return {"error": "payload is required"}
 
             # Try to extract identity from the payload before processing
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 400 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 400 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 23 warnings in 16.97s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -82,7 +82,7 @@
 
             # Try to extract identity from the payload before processing
             identity_data = self._decrypt_message1_payload(incoming["payload"])
-            if identity_data:
+            if not identity_data:
                 nonce_client = identity_data.get("nonceClient")
                 identity = identity_data.get("identity", "Unknown_Group")
                 if nonce_client is not None:
.FFFFFFF.FFFFFF...........................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T164932659868Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T164933500489Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

13 failed, 29 passed, 23 warnings in 16.23s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -85,7 +85,7 @@
             if identity_data:
                 nonce_client = identity_data.get("nonceClient")
                 identity = identity_data.get("identity", "Unknown_Group")
-                if nonce_client is not None:
+                if not nonce_client is not None:
                     # Store identity for later correlation with session secret
                     self.pending_identities[nonce_client] = identity
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -102,7 +102,7 @@
         Decrypt message 1 payload to extract identity and nonce_client.
         This allows us to capture the identity before passing to RMAP library.
         """
-        if not PGP_AVAILABLE:
+        if not not PGP_AVAILABLE:
             return None
 
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -108,7 +108,7 @@
         try:
             # Load server private key for decryption
             server_private_key_path = str(Path(__file__).parent / "server_priv.asc")
-            if not Path(server_private_key_path).exists():
+            if not not Path(server_private_key_path).exists():
                 return None
 
             # Load the private key
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.28s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -115,7 +115,7 @@
             server_key, _ = PGPKey.from_file(server_private_key_path)
 
             # Unlock the private key if it's protected
-            if server_key.is_protected:
+            if not server_key.is_protected:
                 passphrase = os.getenv("PRIVKEY_PASSPHRASE", "")
                 if not passphrase:
                     return None
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.84s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -117,7 +117,7 @@
             # Unlock the private key if it's protected
             if server_key.is_protected:
                 passphrase = os.getenv("PRIVKEY_PASSPHRASE", "")
-                if not passphrase:
+                if not not passphrase:
                     return None
                 server_key.unlock(passphrase)
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -150,7 +150,7 @@
         watermarked PDF.
         """
         try:
-            if "payload" not in incoming:
+            if not "payload" not in incoming:
                 return {"error": "payload is required"}
 
             # Use RMAP library to handle message 2
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 400 == 200

E        +  where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 400 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.56s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -157,7 +157,7 @@
             # The library will return {"result": "hex_string"} or {"error": "message"}
             result = self.rmap.handle_message2(incoming)
 
-            if "result" in result:
+            if not "result" in result:
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if not len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -170,7 +170,7 @@
                 # The session secret is (nonce_client << 64) | nonce_server
                 # We can try to find the matching identity
                 identity = self._find_identity_for_session(session_secret)
-                if identity:
+                if not identity:
                     self.session_identities[session_secret] = identity
 
                 # Store watermark metadata for this session
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -194,7 +194,7 @@
         """
         # For simple cases where there's only one pending identity,
         # use it (works for single concurrent session)
-        if self.pending_identities:
+        if not self.pending_identities:
             # Use the first available identity and clear it
             identity = next(iter(self.pending_identities.values()))
             # Clear pending identities since we've used them
.............FF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

        assert response.status_code == 200

        json_data = response.get_json()

        assert "payload" in json_data

    

        # Decrypt response to get the actual nonceServer

        decrypted = decrypt_server_response(

            json_data["payload"],

            client_privkey_path=str(Path(__file__).parent.parent / "client_keys" / "group13-private.asc"),

            passphrase=os.environ.get("PRIVKEY_PASSPHRASE", "")

        )

        nonce_server = decrypted["nonceServer"]

    

        # Step 2: Use that nonceServer in the rmap-get-link call

        encrypted_payload = encrypt_payload_for_server({

            "nonceServer": nonce_server

        })

    

        response = client.post("/api/rmap-get-link", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:585: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

2 failed, 40 passed, 23 warnings in 20.67s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -20,7 +20,7 @@
 try:
     from pgpy import PGPKey, PGPMessage
 
-    PGP_AVAILABLE = True
+    PGP_AVAILABLE = False
 except ImportError:
     PGP_AVAILABLE = False
 
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133800282883Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133801180193Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.46s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -176,7 +176,7 @@
                 # Store watermark metadata for this session
                 self.watermarked_pdfs[session_secret] = {
                     "method": "robust-xmp",
-                    "created": True,
+                    "created": False,
                     "session_secret": session_secret,
                 }
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -22,7 +22,7 @@
 
     PGP_AVAILABLE = True
 except ImportError:
-    PGP_AVAILABLE = False
+    PGP_AVAILABLE = True
 
 
 class SimpleRMAP:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -21,7 +21,7 @@
     from pgpy import PGPKey, PGPMessage
 
     PGP_AVAILABLE = True
-except ImportError:
+except CosmicRayTestingException:
     PGP_AVAILABLE = False
 
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -94,7 +94,7 @@
 
             return result
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
     def _decrypt_message1_payload(self, payload: str) -> dict[str, Any] | None:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -135,7 +135,7 @@
 
             return message_data
 
-        except Exception:
+        except CosmicRayTestingException:
             return None
 
     def handle_message2(self, incoming: dict[str, Any]) -> dict[str, Any]:
............FFF...........................                               [100%]

================================== FAILURES ===================================

_____________________________ test_rmap_initiate ______________________________



client = <FlaskClient <Flask 'server'>>



    def test_rmap_initiate(client):

        # Prepare payload

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        # Call route

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

    

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:527: AssertionError

_____________________________ test_rmap_get_link ______________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_rmap_get_link(client, shared_link):

        # Step 0: Create RMAP service user to assign document to

        resp = client.post("/api/create-user", json={

            "login": "rmap_service",

            "password": "password_rmap",

            "email": "service@rmap.su",

        })  # pragma: allowlist secret

        # Step 1: Initiate RMAP to get nonceServer

        test_nonce = 12345678

        test_identity = "Group_13"

    

        encrypted_payload = encrypt_payload_for_server({

            "nonceClient": test_nonce,

            "identity": test_identity

        })

    

        response = client.post("/api/rmap-initiate", json={"payload": encrypted_payload})

>       assert response.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:567: AssertionError

___________________________ test_get_version_route ____________________________



client = <FlaskClient <Flask 'server'>>, shared_link = {}



    def test_get_version_route(client, shared_link):

>       route = "/api/get-version/" + shared_link.get("version_link").strip()

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       AttributeError: 'NoneType' object has no attribute 'strip'



..\test\test_api.py:604: AttributeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_rmap_initiate - assert 503 == 200

FAILED ..\test\test_api.py::test_rmap_get_link - assert 503 == 200

FAILED ..\test\test_api.py::test_get_version_route - AttributeError: 'NoneTyp...

3 failed, 39 passed, 23 warnings in 16.72s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -184,7 +184,7 @@
 
             return result
 
-        except Exception as e:
+        except CosmicRayTestingException as e:
             return {"error": f"RMAP processing error: {str(e)}"}
 
     def _find_identity_for_session(self, session_secret: str) -> str | None:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.55s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) < 33:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -161,7 +161,7 @@
                 session_secret = result["result"]
 
                 # Ensure it's a 32-character hex string
-                if len(session_secret) < 32:
+                if len(session_secret) < 31:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -162,7 +162,7 @@
 
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
-                    session_secret = session_secret.zfill(32)
+                    session_secret = session_secret.zfill( 33)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -162,7 +162,7 @@
 
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
-                    session_secret = session_secret.zfill(32)
+                    session_secret = session_secret.zfill( 31)
                 elif len(session_secret) > 32:
                     session_secret = session_secret[:32]
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) > 33:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.69s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -163,7 +163,7 @@
                 # Ensure it's a 32-character hex string
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
-                elif len(session_secret) > 32:
+                elif len(session_secret) > 31:
                     session_secret = session_secret[:32]
 
                 # Try to correlate with pending identity
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.66s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -164,7 +164,7 @@
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
-                    session_secret = session_secret[:32]
+                    session_secret = session_secret[: 33]
 
                 # Try to correlate with pending identity
                 # The session secret is (nonce_client << 64) | nonce_server
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- asimple_rmap.py
+++ bsimple_rmap.py
@@ -164,7 +164,7 @@
                 if len(session_secret) < 32:
                     session_secret = session_secret.zfill(32)
                 elif len(session_secret) > 32:
-                    session_secret = session_secret[:32]
+                    session_secret = session_secret[: 31]
 
                 # Try to correlate with pending identity
                 # The session secret is (nonce_client << 64) | nonce_server
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.21s

operator: core/ReplaceBinaryOperator_Add_Sub, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 - 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T134800378199Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T134801211641Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.51s

operator: core/ReplaceBinaryOperator_Add_Mul, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 * 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T161417552055Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T161418362078Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.51s

operator: core/ReplaceBinaryOperator_Add_Div, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 / 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_Add_FloorDiv, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 // 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_Add_Mod, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 % 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.37s

operator: core/ReplaceBinaryOperator_Add_Pow, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 ** 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_Add_RShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 >> 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Add_LShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 << 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_Add_BitOr, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 | 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Add_BitAnd, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 & 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_Add_BitXor, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 ^ 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.71s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height + margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_Sub_Add, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 + 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height * margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceBinaryOperator_Sub_Mul, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 * 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height / margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ReplaceBinaryOperator_Sub_Div, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 / 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height // margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ReplaceBinaryOperator_Sub_FloorDiv, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 // 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height % margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_Sub_Mod, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 % 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.88s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height ** margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T162552878773Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T162553812119Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.50s

operator: core/ReplaceBinaryOperator_Sub_Pow, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 ** 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.21s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height >> margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_Sub_RShift, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 >> 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.62s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height << margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceBinaryOperator_Sub_LShift, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 << 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height | margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194829731759Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194830601342Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.43s

operator: core/ReplaceBinaryOperator_Sub_BitOr, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 | 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height & margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
.FFFFF.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194642288933Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T194643144773Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

9 failed, 33 passed, 23 warnings in 20.65s

operator: core/ReplaceBinaryOperator_Sub_BitAnd, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 & 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -275,7 +275,7 @@
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
-            tl_point = (margin, page.rect.height - margin)
+            tl_point = (margin, page.rect.height ^ margin)
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_Sub_BitXor, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 ^ 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str + None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.89s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str + None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int + None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 + 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 + 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 + 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes + None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_BitOr_Add, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes + bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002D5C371BBC0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002D5C264D340>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-184/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002D5C264D340>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-184/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str - None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T145432705114Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T145433594052Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.54s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str - None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int - None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.19s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 - 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.39s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 - 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T223952567905Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T223953397097Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.46s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 - 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.44s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes - None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/ReplaceBinaryOperator_BitOr_Sub, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes - bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E01DC67F50>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001E01CB8D1C0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1652/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001E01CB8D1C0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1652/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.27s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str * None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str * None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int * None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 * 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 * 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 * 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 23.49s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes * None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/ReplaceBinaryOperator_BitOr_Mul, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes * bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F59568BD40>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F5945A9160>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1396/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F5945A9160>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1396/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 20.99s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str / None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str / None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102006775923Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102007693420Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.56s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int / None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T225541923653Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T225542769351Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.53s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 / 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 / 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 / 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.44s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes / None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_BitOr_Div, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes / bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C85A6F7E90>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001C85A6334A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-962/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001C85A6334A0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-962/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.27s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str // None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T232137128896Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T232137973007Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.53s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str // None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int // None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 // 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 // 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.63s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 // 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.13s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes // None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102627158776Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T102628065794Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 22.48s

operator: core/ReplaceBinaryOperator_BitOr_FloorDiv, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes // bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002150534BD10>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000021504268F80>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1816/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000021504268F80>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1816/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str % None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str % None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int % None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 % 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 % 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.23s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 % 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes % None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_BitOr_Mod, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes % bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000012F614E7F50>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000012F614233E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2131/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000012F614233E0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2131/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ** None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ** None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.16s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int ** None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.09s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 ** 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T132757952247Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T132758848073Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.66s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 ** 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T185850500012Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T185851332731Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.34s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 ** 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes ** None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_Pow, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes ** bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001ABD6857F50>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001ABD6793500>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1684/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001ABD6793500>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1684/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.02s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str >> None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str >> None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int >> None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T165429428557Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T165430285990Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.76s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 >> 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 >> 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 23.54s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 >> 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.57s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes >> None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceBinaryOperator_BitOr_RShift, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes >> bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002D202D97E00>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002D202CD3350>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1913/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002D202CD3350>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1913/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.14s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str << None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str << None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int << None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.17s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 << 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 << 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 << 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.55s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes << None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_BitOr_LShift, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes << bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000029CACA67D10>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000029CAC9A3410>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1183/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000029CAC9A3410>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1183/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.04s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str & None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str & None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.43s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int & None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 & 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.88s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 & 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 & 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes & None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T103103680170Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T103104553314Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.55s

operator: core/ReplaceBinaryOperator_BitOr_BitAnd, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes & bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BDB35B7FE0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001BDB34F3350>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1584/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001BDB34F3350>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1584/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 20.91s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -74,7 +74,7 @@
         pdf: PdfSource,
         secret: str,
         key: str,
-        intended_for: str | None = None,
+        intended_for: str ^ None = None,
         position: str | None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -75,7 +75,7 @@
         secret: str,
         key: str,
         intended_for: str | None = None,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -158,7 +158,7 @@
     def is_watermark_applicable(
         self,
         pdf: PdfSource,
-        position: str | None = None,
+        position: str ^ None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
             return False
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -230,7 +230,7 @@
     # Internal helpers
     # ---------------------
     def _derive_key(
-        self, password: str, salt: bytes, iter_override: int | None = None
+        self, password: str, salt: bytes, iter_override: int ^ None = None
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 ^ 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 ^ 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 ^ 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.27s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -308,7 +308,7 @@
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
-    def _extract_manifest(self, doc: pymupdf.Document) -> bytes | None:
+    def _extract_manifest(self, doc: pymupdf.Document) -> bytes ^ None:
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.21s

operator: core/ReplaceBinaryOperator_BitOr_BitXor, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if isinstance(file_bytes, bytes ^ bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000288DF93BB00>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000288DF8730E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1972/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000288DF8730E0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1972/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.04s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count != 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
....................F.....................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000027042747890>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002704167D250>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

        out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )

        assert isinstance(out_bytes, bytes | bytearray), (  # nosec B101

            f"{method_name}: add_watermark must return bytes"

        )

>       assert len(out_bytes) >= len(original), (  # nosec B101

            f"{method_name}: watermarked bytes should not be smaller than input"

        )

E       AssertionError: signed-annots: watermarked bytes should not be smaller than input

E       assert 2186 >= 38471

E        +  where 2186 = len(b'%PDF-1.7\n%\xc2\xb5\xc2\xb6\n\n1 0 obj\n<</Type/Catalog/Pages 2 0 R/Names<</EmbeddedFiles<</Names[(WM-TATOU-SIGNED-v...Size 9/Root 1 0 R/ID[<C2A0C293C3ADC289C2BB794500C2B3C3><2A8BE7623BA2C17A03E5FC6A1452B0A4>]>>\nstartxref\n1871\n%%EOF\n')

E        +  and   38471 = len(b'%PDF-1.5\n%\xc3\xa4\xc3\xbc\xc3\xb6\xc3\x9f\n2 0 obj\n<</Length 3 0 R/Filter/FlateDecode>>\nstream\nx\x9c\xadZK\x8f\...>\n<131B47C29D42EE0998F8FBFA411127C3> ]\n/DocChecksum /EC879B7D25D058FE1A4352DCEF098D78\n>>\nstartxref\n37827\n%%EOF\n')



..\test\test_watermarking_all_methods.py:97: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

1 failed, 41 passed, 23 warnings in 21.30s

operator: core/ReplaceComparisonOperator_Eq_NotEq, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count != 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.75s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count < 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/ReplaceComparisonOperator_Eq_Lt, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count < 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count <= 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceComparisonOperator_Eq_LtE, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count <= 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.98s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count > 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
....................F.....................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000016A8CBE7890>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000016A8CB23410>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

        out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )

        assert isinstance(out_bytes, bytes | bytearray), (  # nosec B101

            f"{method_name}: add_watermark must return bytes"

        )

>       assert len(out_bytes) >= len(original), (  # nosec B101

            f"{method_name}: watermarked bytes should not be smaller than input"

        )

E       AssertionError: signed-annots: watermarked bytes should not be smaller than input

E       assert 2185 >= 38471

E        +  where 2185 = len(b'%PDF-1.7\n%\xc2\xb5\xc2\xb6\n\n1 0 obj\n<</Type/Catalog/Pages 2 0 R/Names<</EmbeddedFiles<</Names[(WM-TATOU-SIGNED-v...Size 9/Root 1 0 R/ID[<C2BFC3BDC399C38E52C3BA681D43C39A><2A55B207B383C5F8725FB840FCE3A451>]>>\nstartxref\n1870\n%%EOF\n')

E        +  and   38471 = len(b'%PDF-1.5\n%\xc3\xa4\xc3\xbc\xc3\xb6\xc3\x9f\n2 0 obj\n<</Length 3 0 R/Filter/FlateDecode>>\nstream\nx\x9c\xadZK\x8f\...>\n<131B47C29D42EE0998F8FBFA411127C3> ]\n/DocChecksum /EC879B7D25D058FE1A4352DCEF098D78\n>>\nstartxref\n37827\n%%EOF\n')



..\test\test_watermarking_all_methods.py:97: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/ReplaceComparisonOperator_Eq_Gt, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count > 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.65s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count >= 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
....................F.....................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F2EE11B530>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F2EE053020>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

        out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )

        assert isinstance(out_bytes, bytes | bytearray), (  # nosec B101

            f"{method_name}: add_watermark must return bytes"

        )

>       assert len(out_bytes) >= len(original), (  # nosec B101

            f"{method_name}: watermarked bytes should not be smaller than input"

        )

E       AssertionError: signed-annots: watermarked bytes should not be smaller than input

E       assert 2185 >= 38471

E        +  where 2185 = len(b'%PDF-1.7\n%\xc2\xb5\xc2\xb6\n\n1 0 obj\n<</Type/Catalog/Pages 2 0 R/Names<</EmbeddedFiles<</Names[(WM-TATOU-SIGNED-v...Size 9/Root 1 0 R/ID[<C388C29B55C39163012DC388C39BC389><52934FAAE32AA9422BED64B2BCDA986C>]>>\nstartxref\n1870\n%%EOF\n')

E        +  and   38471 = len(b'%PDF-1.5\n%\xc3\xa4\xc3\xbc\xc3\xb6\xc3\x9f\n2 0 obj\n<</Length 3 0 R/Filter/FlateDecode>>\nstream\nx\x9c\xadZK\x8f\...>\n<131B47C29D42EE0998F8FBFA411127C3> ]\n/DocChecksum /EC879B7D25D058FE1A4352DCEF098D78\n>>\nstartxref\n37827\n%%EOF\n')



..\test\test_watermarking_all_methods.py:97: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

1 failed, 41 passed, 23 warnings in 21.15s

operator: core/ReplaceComparisonOperator_Eq_GtE, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count >= 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/ReplaceComparisonOperator_NotEq_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual == expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000024142727E30>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000241415ACE60>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2084/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:223: in read_secret

    self._verify_object_hashes(doc, payload.get("objs", []))

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000241415ACE60>

doc = closed Document('None', <memory, doc# 23>)

entries = [{'sha256': '3b4bc584aeb83b71e5ea5395f7304e1176dfdcb35cbcd6080ea23be9cf05e7b2', 'xref': 1}, {'sha256': '20f81d356c4e94...8ef5d4418', 'xref': 7}, {'sha256': '3beab1e106528ed004d6d2f548364a9c3381cf379ebc552f8cb18f7a3ecbc5c5', 'xref': 8}, ...]



    def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:

        for e in entries:

            try:

                xref = int(e.get("xref"))

                expected = str(e.get("sha256"))

            except Exception:

                raise WatermarkingError("Malformed object hash entry") from None

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception:

                raise WatermarkingError(

                    "Referenced object missing (tampered)"

                ) from None

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            actual = self._sha256(b)

            if actual == expected:

>               raise WatermarkingError(

                    f"PDF appears tampered: object hash mismatch (xref {xref})"

                )

E               watermarking_method.WatermarkingError: PDF appears tampered: object hash mismatch (xref 1)



signed_annotation_watermark.py:344: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.33s

operator: core/ReplaceComparisonOperator_NotEq_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual < expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.65s

operator: core/ReplaceComparisonOperator_NotEq_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual <= expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C6B0F57D40>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001C6AFE8D2B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1874/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:223: in read_secret

    self._verify_object_hashes(doc, payload.get("objs", []))

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001C6AFE8D2B0>

doc = closed Document('None', <memory, doc# 23>)

entries = [{'sha256': '3b4bc584aeb83b71e5ea5395f7304e1176dfdcb35cbcd6080ea23be9cf05e7b2', 'xref': 1}, {'sha256': '20f81d356c4e94...8ef5d4418', 'xref': 7}, {'sha256': '3beab1e106528ed004d6d2f548364a9c3381cf379ebc552f8cb18f7a3ecbc5c5', 'xref': 8}, ...]



    def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:

        for e in entries:

            try:

                xref = int(e.get("xref"))

                expected = str(e.get("sha256"))

            except Exception:

                raise WatermarkingError("Malformed object hash entry") from None

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception:

                raise WatermarkingError(

                    "Referenced object missing (tampered)"

                ) from None

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            actual = self._sha256(b)

            if actual <= expected:

>               raise WatermarkingError(

                    f"PDF appears tampered: object hash mismatch (xref {xref})"

                )

E               watermarking_method.WatermarkingError: PDF appears tampered: object hash mismatch (xref 1)



signed_annotation_watermark.py:344: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.23s

operator: core/ReplaceComparisonOperator_NotEq_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual > expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/ReplaceComparisonOperator_NotEq_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual >= expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000221898D7E60>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022186D10A10>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1682/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:223: in read_secret

    self._verify_object_hashes(doc, payload.get("objs", []))

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022186D10A10>

doc = closed Document('None', <memory, doc# 23>)

entries = [{'sha256': '3b4bc584aeb83b71e5ea5395f7304e1176dfdcb35cbcd6080ea23be9cf05e7b2', 'xref': 1}, {'sha256': '20f81d356c4e94...8ef5d4418', 'xref': 7}, {'sha256': '3beab1e106528ed004d6d2f548364a9c3381cf379ebc552f8cb18f7a3ecbc5c5', 'xref': 8}, ...]



    def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:

        for e in entries:

            try:

                xref = int(e.get("xref"))

                expected = str(e.get("sha256"))

            except Exception:

                raise WatermarkingError("Malformed object hash entry") from None

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception:

                raise WatermarkingError(

                    "Referenced object missing (tampered)"

                ) from None

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            actual = self._sha256(b)

            if actual >= expected:

>               raise WatermarkingError(

                    f"PDF appears tampered: object hash mismatch (xref {xref})"

                )

E               watermarking_method.WatermarkingError: PDF appears tampered: object hash mismatch (xref 1)



signed_annotation_watermark.py:344: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.14s

operator: core/ReplaceComparisonOperator_NotEq_Is, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual is expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/ReplaceComparisonOperator_NotEq_IsNot, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if actual is not expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001EA3AA3BC80>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001EA3A9733B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1463/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:223: in read_secret

    self._verify_object_hashes(doc, payload.get("objs", []))

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001EA3A9733B0>

doc = closed Document('None', <memory, doc# 23>)

entries = [{'sha256': '3b4bc584aeb83b71e5ea5395f7304e1176dfdcb35cbcd6080ea23be9cf05e7b2', 'xref': 1}, {'sha256': '20f81d356c4e94...8ef5d4418', 'xref': 7}, {'sha256': '3beab1e106528ed004d6d2f548364a9c3381cf379ebc552f8cb18f7a3ecbc5c5', 'xref': 8}, ...]



    def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:

        for e in entries:

            try:

                xref = int(e.get("xref"))

                expected = str(e.get("sha256"))

            except Exception:

                raise WatermarkingError("Malformed object hash entry") from None

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception:

                raise WatermarkingError(

                    "Referenced object missing (tampered)"

                ) from None

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            actual = self._sha256(b)

            if actual is not expected:

>               raise WatermarkingError(

                    f"PDF appears tampered: object hash mismatch (xref {xref})"

                )

E               watermarking_method.WatermarkingError: PDF appears tampered: object hash mismatch (xref 1)



signed_annotation_watermark.py:344: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.15s

operator: core/ReplaceComparisonOperator_Lt_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) == 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceComparisonOperator_Lt_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) != 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.25s

operator: core/ReplaceComparisonOperator_Lt_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) <= 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.03s

operator: core/ReplaceComparisonOperator_Lt_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) > 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceComparisonOperator_Lt_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) >= 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.54s

operator: core/ReplaceComparisonOperator_LtE_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count == 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceComparisonOperator_LtE_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count != 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002321304BBF0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000023212F83050>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-711/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000023212F83050>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-711/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

                raise SecretNotFoundError("Signed annotation watermark not found")

    

            try:

                manifest = json.loads(manifest_bytes.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Malformed watermark manifest") from exc

    

            salt = base64.b64decode(manifest["salt"])

            nonce = base64.b64decode(manifest["nonce"])

            ct = base64.b64decode(manifest["ct"])

            iter_count = int(manifest.get("iter", self._PBKDF2_ITER))

            # Limit to 300k iterations to prevent DoS attacks

            # triggered by excessive PBKDF2 computation

            if iter_count != 0 or iter_count > 300_000:

>               raise WatermarkingError("Unreasonable PBKDF2 iteration count")

E               watermarking_method.WatermarkingError: Unreasonable PBKDF2 iteration count



signed_annotation_watermark.py:202: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/ReplaceComparisonOperator_LtE_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count < 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_LtE_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count > 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BECF8C7DD0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001BECE7FD3A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1176/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001BECE7FD3A0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1176/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

                raise SecretNotFoundError("Signed annotation watermark not found")

    

            try:

                manifest = json.loads(manifest_bytes.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Malformed watermark manifest") from exc

    

            salt = base64.b64decode(manifest["salt"])

            nonce = base64.b64decode(manifest["nonce"])

            ct = base64.b64decode(manifest["ct"])

            iter_count = int(manifest.get("iter", self._PBKDF2_ITER))

            # Limit to 300k iterations to prevent DoS attacks

            # triggered by excessive PBKDF2 computation

            if iter_count > 0 or iter_count > 300_000:

>               raise WatermarkingError("Unreasonable PBKDF2 iteration count")

E               watermarking_method.WatermarkingError: Unreasonable PBKDF2 iteration count



signed_annotation_watermark.py:202: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.09s

operator: core/ReplaceComparisonOperator_LtE_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count >= 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002509BB2BD70>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000025098FD5EB0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2478/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000025098FD5EB0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2478/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

                raise SecretNotFoundError("Signed annotation watermark not found")

    

            try:

                manifest = json.loads(manifest_bytes.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Malformed watermark manifest") from exc

    

            salt = base64.b64decode(manifest["salt"])

            nonce = base64.b64decode(manifest["nonce"])

            ct = base64.b64decode(manifest["ct"])

            iter_count = int(manifest.get("iter", self._PBKDF2_ITER))

            # Limit to 300k iterations to prevent DoS attacks

            # triggered by excessive PBKDF2 computation

            if iter_count >= 0 or iter_count > 300_000:

>               raise WatermarkingError("Unreasonable PBKDF2 iteration count")

E               watermarking_method.WatermarkingError: Unreasonable PBKDF2 iteration count



signed_annotation_watermark.py:202: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 20.77s

operator: core/ReplaceComparisonOperator_Gt_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count == 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceComparisonOperator_Gt_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count != 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026D2381BBF0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000026D20C453D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-803/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000026D20C453D0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-803/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

                raise SecretNotFoundError("Signed annotation watermark not found")

    

            try:

                manifest = json.loads(manifest_bytes.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Malformed watermark manifest") from exc

    

            salt = base64.b64decode(manifest["salt"])

            nonce = base64.b64decode(manifest["nonce"])

            ct = base64.b64decode(manifest["ct"])

            iter_count = int(manifest.get("iter", self._PBKDF2_ITER))

            # Limit to 300k iterations to prevent DoS attacks

            # triggered by excessive PBKDF2 computation

            if iter_count <= 0 or iter_count != 300_000:

>               raise WatermarkingError("Unreasonable PBKDF2 iteration count")

E               watermarking_method.WatermarkingError: Unreasonable PBKDF2 iteration count



signed_annotation_watermark.py:202: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 20.97s

operator: core/ReplaceComparisonOperator_Gt_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count < 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E1F93C7EC0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001E1F93036B0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-825/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001E1F93036B0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-825/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

                raise SecretNotFoundError("Signed annotation watermark not found")

    

            try:

                manifest = json.loads(manifest_bytes.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Malformed watermark manifest") from exc

    

            salt = base64.b64decode(manifest["salt"])

            nonce = base64.b64decode(manifest["nonce"])

            ct = base64.b64decode(manifest["ct"])

            iter_count = int(manifest.get("iter", self._PBKDF2_ITER))

            # Limit to 300k iterations to prevent DoS attacks

            # triggered by excessive PBKDF2 computation

            if iter_count <= 0 or iter_count < 300_000:

>               raise WatermarkingError("Unreasonable PBKDF2 iteration count")

E               watermarking_method.WatermarkingError: Unreasonable PBKDF2 iteration count



signed_annotation_watermark.py:202: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 20.73s

operator: core/ReplaceComparisonOperator_Gt_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count <= 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001CD15147E90>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001CD14069460>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-685/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001CD14069460>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-685/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

                raise SecretNotFoundError("Signed annotation watermark not found")

    

            try:

                manifest = json.loads(manifest_bytes.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Malformed watermark manifest") from exc

    

            salt = base64.b64decode(manifest["salt"])

            nonce = base64.b64decode(manifest["nonce"])

            ct = base64.b64decode(manifest["ct"])

            iter_count = int(manifest.get("iter", self._PBKDF2_ITER))

            # Limit to 300k iterations to prevent DoS attacks

            # triggered by excessive PBKDF2 computation

            if iter_count <= 0 or iter_count <= 300_000:

>               raise WatermarkingError("Unreasonable PBKDF2 iteration count")

E               watermarking_method.WatermarkingError: Unreasonable PBKDF2 iteration count



signed_annotation_watermark.py:202: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 20.95s

operator: core/ReplaceComparisonOperator_Gt_GtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count >= 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceComparisonOperator_GtE_Eq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) == self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ReplaceComparisonOperator_GtE_NotEq, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) != self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ReplaceComparisonOperator_GtE_Lt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) < self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T181141749523Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T181142581856Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.48s

operator: core/ReplaceComparisonOperator_GtE_LtE, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) <= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/ReplaceComparisonOperator_GtE_Gt, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) > self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133528635666Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T133529522752Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.58s

operator: core/ReplaceComparisonOperator_GtE_Is, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) is self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.81s

operator: core/ReplaceComparisonOperator_GtE_IsNot, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if len(out) is not self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T192808186834Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T192809085180Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.45s

operator: core/ReplaceComparisonOperator_Is_IsNot, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -184,7 +184,7 @@
         doc = pymupdf.open(stream=data, filetype="pdf")
         try:
             manifest_bytes = self._extract_manifest(doc)
-            if manifest_bytes is None:
+            if manifest_bytes is not None:
                 raise SecretNotFoundError("Signed annotation watermark not found")
 
             try:
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000016894687F50>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000168945C34D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-946/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000168945C34D0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-946/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is not None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 20.84s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -77,7 +77,7 @@
         intended_for: str | None = None,
         position: str | None = None,
     ) -> bytes:
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000260FC1FB8C0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000260FB234380>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000260FB234380>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if  HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for this watermark method")

E           watermarking_method.WatermarkingError: PyMuPDF is required for this watermark method



signed_annotation_watermark.py:81: WatermarkingError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000260FC1FBE30>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000260FB234380>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-585/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000260FB234380>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if  HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for this watermark method")

E           watermarking_method.WatermarkingError: PyMuPDF is required for this watermark method



signed_annotation_watermark.py:81: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 20.56s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -79,7 +79,7 @@
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not secret or not isinstance(secret, str):
+        if  secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022CB3EC7830>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022CB2DFD1F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022CB2DFD1F0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if  secret or not isinstance(secret, str):

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



signed_annotation_watermark.py:83: ValueError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022CB3EC7DA0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022CB2DFD1F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-616/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022CB2DFD1F0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if  secret or not isinstance(secret, str):

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



signed_annotation_watermark.py:83: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 20.82s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -79,7 +79,7 @@
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not secret or not isinstance(secret, str):
+        if not secret or  isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
.FFF.F.F.FFF........F..F..................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T183017996706Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T183018842277Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000263ADC3B560>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263ADB73080>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263ADB73080>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or  isinstance(secret, str):

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



signed_annotation_watermark.py:83: ValueError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000263ADC3BAD0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263ADB73080>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1460/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263ADB73080>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or  isinstance(secret, str):

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



signed_annotation_watermark.py:83: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

10 failed, 32 passed, 23 warnings in 20.40s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -81,7 +81,7 @@
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
-        if not key or not isinstance(key, str):
+        if  key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         original = load_pdf_bytes(pdf)
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002B40B5B77D0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002B40B4F34A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002B40B4F34A0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if  key or not isinstance(key, str):

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



signed_annotation_watermark.py:85: ValueError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002B40B5B7D40>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002B40B4F34A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1880/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002B40B4F34A0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if  key or not isinstance(key, str):

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



signed_annotation_watermark.py:85: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 20.72s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -81,7 +81,7 @@
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
-        if not key or not isinstance(key, str):
+        if not key or  isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         original = load_pdf_bytes(pdf)
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000263222A7920>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263221E34A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263221E34A0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or  isinstance(key, str):

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



signed_annotation_watermark.py:85: ValueError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000263222A7E90>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263221E34A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-448/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263221E34A0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or  isinstance(key, str):

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



signed_annotation_watermark.py:85: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 21.79s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         position: str | None = None,
     ) -> bool:
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             return False
         try:
             b = load_pdf_bytes(pdf)
.................s..s..s..................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

39 passed, 3 skipped, 23 warnings in 20.62s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -175,7 +175,7 @@
         return True
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
-        if not HAS_PYMUPDF:
+        if  HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F4524D7CE0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F452413380>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2333/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F452413380>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2333/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if  HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for this watermark method")

E           watermarking_method.WatermarkingError: PyMuPDF is required for this watermark method



signed_annotation_watermark.py:179: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 22.17s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -177,7 +177,7 @@
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not key or not isinstance(key, str):
+        if  key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         data = load_pdf_bytes(pdf)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000283C1A4BE00>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000283C097D220>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-417/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000283C097D220>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-417/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if  key or not isinstance(key, str):

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



signed_annotation_watermark.py:181: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.24s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -177,7 +177,7 @@
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not key or not isinstance(key, str):
+        if not key or  isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         data = load_pdf_bytes(pdf)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000263D23B7EC0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263D12DD1F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1332/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000263D12DD1F0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1332/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or  isinstance(key, str):

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



signed_annotation_watermark.py:181: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.05s

operator: core/ReplaceUnaryOperator_Delete_Not, occurrence: 9
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -216,7 +216,7 @@
                 raise SecretNotFoundError("Corrupted decrypted payload") from exc
 
             # Validate structure
-            if not (isinstance(payload, dict) and payload.get("secret")):
+            if  (isinstance(payload, dict) and payload.get("secret")):
                 raise SecretNotFoundError("Decrypted payload missing secret field")
 
             # Tamper check: recompute each hashed object
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001D3050E7F50>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001D305023410>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1382/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001D305023410>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1382/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

                raise SecretNotFoundError("Signed annotation watermark not found")

    

            try:

                manifest = json.loads(manifest_bytes.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Malformed watermark manifest") from exc

    

            salt = base64.b64decode(manifest["salt"])

            nonce = base64.b64decode(manifest["nonce"])

            ct = base64.b64decode(manifest["ct"])

            iter_count = int(manifest.get("iter", self._PBKDF2_ITER))

            # Limit to 300k iterations to prevent DoS attacks

            # triggered by excessive PBKDF2 computation

            if iter_count <= 0 or iter_count > 300_000:

                raise WatermarkingError("Unreasonable PBKDF2 iteration count")

    

            key_bytes = self._derive_key(key, salt, iter_override=iter_count)

            aes = AESGCM(key_bytes)

            try:

                pt = aes.decrypt(nonce, ct, None)

            except Exception as exc:

                raise InvalidKeyError(

                    "Failed to authenticate watermark (key?)"

                ) from exc

    

            try:

                payload = json.loads(pt.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Corrupted decrypted payload") from exc

    

            # Validate structure

            if  (isinstance(payload, dict) and payload.get("secret")):

>               raise SecretNotFoundError("Decrypted payload missing secret field")

E               watermarking_method.SecretNotFoundError: Decrypted payload missing secret field



signed_annotation_watermark.py:220: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.24s

operator: core/AddNot, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -77,7 +77,7 @@
         intended_for: str | None = None,
         position: str | None = None,
     ) -> bytes:
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002E3FAC37920>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002E3F9B693D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002E3F9B693D0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not not HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for this watermark method")

E           watermarking_method.WatermarkingError: PyMuPDF is required for this watermark method



signed_annotation_watermark.py:81: WatermarkingError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002E3FAC37E90>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002E3F9B693D0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1288/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002E3F9B693D0>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not not HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for this watermark method")

E           watermarking_method.WatermarkingError: PyMuPDF is required for this watermark method



signed_annotation_watermark.py:81: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 21.08s

operator: core/AddNot, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -79,7 +79,7 @@
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not secret or not isinstance(secret, str):
+        if not not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
.FFF.F.F.FFF........F..F..................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T143019401671Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T143020230763Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F8BEAAB590>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F8BE9B8680>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F8BE9B8680>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not not secret or not isinstance(secret, str):

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



signed_annotation_watermark.py:83: ValueError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F8BEAABB00>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F8BE9B8680>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-808/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F8BE9B8680>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not not secret or not isinstance(secret, str):

>           raise ValueError("Secret must be a non-empty string")

E           ValueError: Secret must be a non-empty string



signed_annotation_watermark.py:83: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

10 failed, 32 passed, 23 warnings in 20.12s

operator: core/AddNot, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -81,7 +81,7 @@
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
-        if not key or not isinstance(key, str):
+        if not not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         original = load_pdf_bytes(pdf)
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019BDF3DB7D0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000019BDF313440>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000019BDF313440>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not not key or not isinstance(key, str):

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



signed_annotation_watermark.py:85: ValueError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019BDF3DBD40>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000019BDF313440>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-852/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000019BDF313440>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not not key or not isinstance(key, str):

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



signed_annotation_watermark.py:85: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 20.86s

operator: core/AddNot, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if not doc.page_count == 0:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
....................F.....................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000198FFB277A0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000198FFA635C0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

        out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )

        assert isinstance(out_bytes, bytes | bytearray), (  # nosec B101

            f"{method_name}: add_watermark must return bytes"

        )

>       assert len(out_bytes) >= len(original), (  # nosec B101

            f"{method_name}: watermarked bytes should not be smaller than input"

        )

E       AssertionError: signed-annots: watermarked bytes should not be smaller than input

E       assert 2186 >= 38471

E        +  where 2186 = len(b'%PDF-1.7\n%\xc2\xb5\xc2\xb6\n\n1 0 obj\n<</Type/Catalog/Pages 2 0 R/Names<</EmbeddedFiles<</Names[(WM-TATOU-SIGNED-v...Size 9/Root 1 0 R/ID[<50C2BA5253C3B3C28771C3B2C3B4376A><FB526BCC94500E0D63FC91A5FD500D06>]>>\nstartxref\n1871\n%%EOF\n')

E        +  and   38471 = len(b'%PDF-1.5\n%\xc3\xa4\xc3\xbc\xc3\xb6\xc3\x9f\n2 0 obj\n<</Length 3 0 R/Filter/FlateDecode>>\nstream\nx\x9c\xadZK\x8f\...>\n<131B47C29D42EE0998F8FBFA411127C3> ]\n/DocChecksum /EC879B7D25D058FE1A4352DCEF098D78\n>>\nstartxref\n37827\n%%EOF\n')



..\test\test_watermarking_all_methods.py:97: AssertionError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

1 failed, 41 passed, 23 warnings in 21.05s

operator: core/AddNot, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -129,7 +129,7 @@
             }
             manifest_bytes = json.dumps(manifest, separators=(",", ":")).encode("utf-8")
             try:
-                if (
+                if not (
                     hasattr(doc, "_embfile_names")
                     and self._EMBED_NAME in doc._embfile_names()
                 ):
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.72s

operator: core/AddNot, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -137,7 +137,7 @@
             except Exception as exc:
                 logger.debug("Cleanup of existing embedded file failed: %s", exc)
             try:
-                if hasattr(doc, "_embfile_add"):
+                if not hasattr(doc, "_embfile_add"):
                     doc.embfile_add(
                         self._EMBED_NAME,
                         manifest_bytes,
.FFFFFFF.FFF...........F..................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T233850449854Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T233851337267Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000214AFFB7DA0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000214AFEF32F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2296/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000214AFEF32F0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2296/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

11 failed, 31 passed, 23 warnings in 20.54s

operator: core/AddNot, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -160,7 +160,7 @@
         pdf: PdfSource,
         position: str | None = None,
     ) -> bool:
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             return False
         try:
             b = load_pdf_bytes(pdf)
.................s..s..s..................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

39 passed, 3 skipped, 23 warnings in 20.77s

operator: core/AddNot, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -175,7 +175,7 @@
         return True
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
-        if not HAS_PYMUPDF:
+        if not not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000002A137187DA0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002A1370C34A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1574/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000002A1370C34A0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1574/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not not HAS_PYMUPDF:

>           raise WatermarkingError("PyMuPDF is required for this watermark method")

E           watermarking_method.WatermarkingError: PyMuPDF is required for this watermark method



signed_annotation_watermark.py:179: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.30s

operator: core/AddNot, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -177,7 +177,7 @@
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not key or not isinstance(key, str):
+        if not not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         data = load_pdf_bytes(pdf)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000185E0C07E00>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000185E0B435C0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2001/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000185E0B435C0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2001/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not not key or not isinstance(key, str):

>           raise ValueError("Key must be a non-empty string")

E           ValueError: Key must be a non-empty string



signed_annotation_watermark.py:181: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 20.91s

operator: core/AddNot, occurrence: 9
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -184,7 +184,7 @@
         doc = pymupdf.open(stream=data, filetype="pdf")
         try:
             manifest_bytes = self._extract_manifest(doc)
-            if manifest_bytes is None:
+            if not manifest_bytes is None:
                 raise SecretNotFoundError("Signed annotation watermark not found")
 
             try:
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001B3DDCEBCE0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001B3DDC23230>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2369/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001B3DDC23230>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2369/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if not manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.49s

operator: core/AddNot, occurrence: 10
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if not iter_count <= 0 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001F1795CBA40>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F17894F680>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1330/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001F17894F680>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1330/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

                raise SecretNotFoundError("Signed annotation watermark not found")

    

            try:

                manifest = json.loads(manifest_bytes.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Malformed watermark manifest") from exc

    

            salt = base64.b64decode(manifest["salt"])

            nonce = base64.b64decode(manifest["nonce"])

            ct = base64.b64decode(manifest["ct"])

            iter_count = int(manifest.get("iter", self._PBKDF2_ITER))

            # Limit to 300k iterations to prevent DoS attacks

            # triggered by excessive PBKDF2 computation

            if not iter_count <= 0 or iter_count > 300_000:

>               raise WatermarkingError("Unreasonable PBKDF2 iteration count")

E               watermarking_method.WatermarkingError: Unreasonable PBKDF2 iteration count



signed_annotation_watermark.py:202: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.35s

operator: core/AddNot, occurrence: 11
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -216,7 +216,7 @@
                 raise SecretNotFoundError("Corrupted decrypted payload") from exc
 
             # Validate structure
-            if not (isinstance(payload, dict) and payload.get("secret")):
+            if not not (isinstance(payload, dict) and payload.get("secret")):
                 raise SecretNotFoundError("Decrypted payload missing secret field")
 
             # Tamper check: recompute each hashed object
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026F39CABA10>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000026F39BE2ED0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-379/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000026F39BE2ED0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-379/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

                raise SecretNotFoundError("Signed annotation watermark not found")

    

            try:

                manifest = json.loads(manifest_bytes.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Malformed watermark manifest") from exc

    

            salt = base64.b64decode(manifest["salt"])

            nonce = base64.b64decode(manifest["nonce"])

            ct = base64.b64decode(manifest["ct"])

            iter_count = int(manifest.get("iter", self._PBKDF2_ITER))

            # Limit to 300k iterations to prevent DoS attacks

            # triggered by excessive PBKDF2 computation

            if iter_count <= 0 or iter_count > 300_000:

                raise WatermarkingError("Unreasonable PBKDF2 iteration count")

    

            key_bytes = self._derive_key(key, salt, iter_override=iter_count)

            aes = AESGCM(key_bytes)

            try:

                pt = aes.decrypt(nonce, ct, None)

            except Exception as exc:

                raise InvalidKeyError(

                    "Failed to authenticate watermark (key?)"

                ) from exc

    

            try:

                payload = json.loads(pt.decode("utf-8"))

            except Exception as exc:

                raise SecretNotFoundError("Corrupted decrypted payload") from exc

    

            # Validate structure

            if not not (isinstance(payload, dict) and payload.get("secret")):

>               raise SecretNotFoundError("Decrypted payload missing secret field")

E               watermarking_method.SecretNotFoundError: Decrypted payload missing secret field



signed_annotation_watermark.py:220: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.18s

operator: core/AddNot, occurrence: 12
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -248,7 +248,7 @@
         except Exception:
             return out
         for xref in range(1, xref_len):
-            if len(out) >= self._OBJ_SAMPLE_LIMIT:
+            if not len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.26s

operator: core/AddNot, occurrence: 13
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -258,7 +258,7 @@
                 )
                 continue
             lower = obj_str.lower()
-            if "/type /catalog" in lower or "/names" in lower:
+            if not "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
             if len(b.strip()) < 8:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.76s

operator: core/AddNot, occurrence: 14
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if not len(b.strip()) < 8:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T135257541778Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T135258601878Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 21.62s

operator: core/AddNot, occurrence: 15
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if not doc.page_count == 0:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T175153132941Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T175154014488Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.68s

operator: core/AddNot, occurrence: 16
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -285,7 +285,7 @@
                 logger.debug("Setting annotation flags failed: %s", exc)
             try:
                 # Ensure it is not auto-open
-                if hasattr(annot, "set_open"):
+                if not hasattr(annot, "set_open"):
                     annot.set_open(False)
             except Exception as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/AddNot, occurrence: 17
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -312,7 +312,7 @@
         # Primary: embedded file
         logger = logging.getLogger(__name__)
         try:
-            if hasattr(doc, "_embfile_names"):
+            if not hasattr(doc, "_embfile_names"):
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001BC65B2BD10>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001BC65A63200>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2473/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001BC65A63200>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2473/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 20.66s

operator: core/AddNot, occurrence: 18
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -314,7 +314,7 @@
         try:
             if hasattr(doc, "_embfile_names"):
                 names = doc.embfile_names()
-                if self._EMBED_NAME in names:
+                if not self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
                     if isinstance(file_bytes, bytes | bytearray):
                         return bytes(file_bytes)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000015A8D687D40>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000015A8D5C35F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-973/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000015A8D5C35F0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-973/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.19s

operator: core/AddNot, occurrence: 19
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -316,7 +316,7 @@
                 names = doc.embfile_names()
                 if self._EMBED_NAME in names:
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
-                    if isinstance(file_bytes, bytes | bytearray):
+                    if not isinstance(file_bytes, bytes | bytearray):
                         return bytes(file_bytes)
         except Exception as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000207B0B0BCE0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000207B0A430E0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-205/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000207B0A430E0>

pdf = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-205/test_read_secret_roundtrip_sig0/signed-annots_watermarked.pdf')

key = 'unit-test-key'



    def read_secret(self, pdf: PdfSource, key: str) -> str:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        data = load_pdf_bytes(pdf)

        doc = pymupdf.open(stream=data, filetype="pdf")

        try:

            manifest_bytes = self._extract_manifest(doc)

            if manifest_bytes is None:

>               raise SecretNotFoundError("Signed annotation watermark not found")

E               watermarking_method.SecretNotFoundError: Signed annotation watermark not found



signed_annotation_watermark.py:188: SecretNotFoundError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.16s

operator: core/AddNot, occurrence: 20
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -336,7 +336,7 @@
                     "Referenced object missing (tampered)"
                 ) from None
             lower = obj_str.lower()
-            if "/type /catalog" in lower or "/names" in lower:
+            if not "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/AddNot, occurrence: 21
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -340,7 +340,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
-            if actual != expected:
+            if not actual != expected:
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000020BBC09BBF0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000020BBBFD3260>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2338/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:223: in read_secret

    self._verify_object_hashes(doc, payload.get("objs", []))

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000020BBBFD3260>

doc = closed Document('None', <memory, doc# 23>)

entries = [{'sha256': '3b4bc584aeb83b71e5ea5395f7304e1176dfdcb35cbcd6080ea23be9cf05e7b2', 'xref': 1}, {'sha256': '20f81d356c4e94...8ef5d4418', 'xref': 7}, {'sha256': '3beab1e106528ed004d6d2f548364a9c3381cf379ebc552f8cb18f7a3ecbc5c5', 'xref': 8}, ...]



    def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:

        for e in entries:

            try:

                xref = int(e.get("xref"))

                expected = str(e.get("sha256"))

            except Exception:

                raise WatermarkingError("Malformed object hash entry") from None

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception:

                raise WatermarkingError(

                    "Referenced object missing (tampered)"

                ) from None

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            actual = self._sha256(b)

            if not actual != expected:

>               raise WatermarkingError(

                    f"PDF appears tampered: object hash mismatch (xref {xref})"

                )

E               watermarking_method.WatermarkingError: PDF appears tampered: object hash mismatch (xref 1)



signed_annotation_watermark.py:344: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.88s

operator: core/ReplaceTrueWithFalse, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -36,7 +36,7 @@
 try:  # PyMuPDF is required for all operations of this method
     import pymupdf
 
-    HAS_PYMUPDF = True
+    HAS_PYMUPDF = False
 except Exception:
     HAS_PYMUPDF = False
 
.................s..s..s..................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

39 passed, 3 skipped, 23 warnings in 20.64s

operator: core/ReplaceTrueWithFalse, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -172,7 +172,7 @@
                 doc.close()
             except Exception as exc:
                 logging.getLogger(__name__).debug("Closing document failed: %s", exc)
-        return True
+        return False
 
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
.................s..s..s..................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

39 passed, 3 skipped, 23 warnings in 20.75s

operator: core/ReplaceFalseWithTrue, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -38,7 +38,7 @@
 
     HAS_PYMUPDF = True
 except Exception:
-    HAS_PYMUPDF = False
+    HAS_PYMUPDF = True
 
 
 @dataclass
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ReplaceFalseWithTrue, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -161,7 +161,7 @@
         position: str | None = None,
     ) -> bool:
         if not HAS_PYMUPDF:
-            return False
+            return True
         try:
             b = load_pdf_bytes(pdf)
             doc = pymupdf.open(stream=b, filetype="pdf")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.10s

operator: core/ReplaceFalseWithTrue, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -166,7 +166,7 @@
             b = load_pdf_bytes(pdf)
             doc = pymupdf.open(stream=b, filetype="pdf")
         except Exception:
-            return False
+            return True
         finally:
             try:
                 doc.close()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.69s

operator: core/ReplaceFalseWithTrue, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -251,7 +251,7 @@
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
-                obj_str = doc.xref_object(xref, compressed=False) or ""
+                obj_str = doc.xref_object(xref, compressed=True) or ""
             except Exception as exc:
                 logging.getLogger(__name__).debug(
                     "Reading xref %s failed: %s", xref, exc
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001E760B2BC50>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001E760A62FC0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2295/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:223: in read_secret

    self._verify_object_hashes(doc, payload.get("objs", []))

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001E760A62FC0>

doc = closed Document('None', <memory, doc# 23>)

entries = [{'sha256': '20ebddee1a94c61a543495bddef74699f5a0d978ee2b5954f10660f2b7c05df0', 'xref': 1}, {'sha256': '3800062d1147d8...7461bc8e4', 'xref': 7}, {'sha256': '519035e35f97b5b1fc22dc454ae544357ffcbb63d06bffde4f311b9a8f8238d5', 'xref': 8}, ...]



    def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:

        for e in entries:

            try:

                xref = int(e.get("xref"))

                expected = str(e.get("sha256"))

            except Exception:

                raise WatermarkingError("Malformed object hash entry") from None

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception:

                raise WatermarkingError(

                    "Referenced object missing (tampered)"

                ) from None

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            actual = self._sha256(b)

            if actual != expected:

>               raise WatermarkingError(

                    f"PDF appears tampered: object hash mismatch (xref {xref})"

                )

E               watermarking_method.WatermarkingError: PDF appears tampered: object hash mismatch (xref 1)



signed_annotation_watermark.py:344: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.11s

operator: core/ReplaceFalseWithTrue, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -286,7 +286,7 @@
             try:
                 # Ensure it is not auto-open
                 if hasattr(annot, "set_open"):
-                    annot.set_open(False)
+                    annot.set_open(True)
             except Exception as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.85s

operator: core/ReplaceFalseWithTrue, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -330,7 +330,7 @@
             except Exception:
                 raise WatermarkingError("Malformed object hash entry") from None
             try:
-                obj_str = doc.xref_object(xref, compressed=False) or ""
+                obj_str = doc.xref_object(xref, compressed=True) or ""
             except Exception:
                 raise WatermarkingError(
                     "Referenced object missing (tampered)"
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000158FCCFBD40>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000158FCC332F0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-660/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:223: in read_secret

    self._verify_object_hashes(doc, payload.get("objs", []))

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000158FCC332F0>

doc = closed Document('None', <memory, doc# 23>)

entries = [{'sha256': '3b4bc584aeb83b71e5ea5395f7304e1176dfdcb35cbcd6080ea23be9cf05e7b2', 'xref': 1}, {'sha256': '20f81d356c4e94...8ef5d4418', 'xref': 7}, {'sha256': '3beab1e106528ed004d6d2f548364a9c3381cf379ebc552f8cb18f7a3ecbc5c5', 'xref': 8}, ...]



    def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:

        for e in entries:

            try:

                xref = int(e.get("xref"))

                expected = str(e.get("sha256"))

            except Exception:

                raise WatermarkingError("Malformed object hash entry") from None

            try:

                obj_str = doc.xref_object(xref, compressed=True) or ""

            except Exception:

                raise WatermarkingError(

                    "Referenced object missing (tampered)"

                ) from None

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            actual = self._sha256(b)

            if actual != expected:

>               raise WatermarkingError(

                    f"PDF appears tampered: object hash mismatch (xref {xref})"

                )

E               watermarking_method.WatermarkingError: PDF appears tampered: object hash mismatch (xref 1)



signed_annotation_watermark.py:344: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.01s

operator: core/ReplaceAndWithOr, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -131,7 +131,7 @@
             try:
                 if (
                     hasattr(doc, "_embfile_names")
-                    and self._EMBED_NAME in doc._embfile_names()
+                    or self._EMBED_NAME in doc._embfile_names()
                 ):
                     doc._embfile_del(self._EMBED_NAME)
             except Exception as exc:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceAndWithOr, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -216,7 +216,7 @@
                 raise SecretNotFoundError("Corrupted decrypted payload") from exc
 
             # Validate structure
-            if not (isinstance(payload, dict) and payload.get("secret")):
+            if not (isinstance(payload, dict) or payload.get("secret")):
                 raise SecretNotFoundError("Decrypted payload missing secret field")
 
             # Tamper check: recompute each hashed object
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/ReplaceOrWithAnd, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -79,7 +79,7 @@
     ) -> bytes:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not secret or not isinstance(secret, str):
+        if not secret and not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
         if not key or not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceOrWithAnd, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -81,7 +81,7 @@
             raise WatermarkingError("PyMuPDF is required for this watermark method")
         if not secret or not isinstance(secret, str):
             raise ValueError("Secret must be a non-empty string")
-        if not key or not isinstance(key, str):
+        if not key and not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         original = load_pdf_bytes(pdf)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.78s

operator: core/ReplaceOrWithAnd, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -177,7 +177,7 @@
     def read_secret(self, pdf: PdfSource, key: str) -> str:
         if not HAS_PYMUPDF:
             raise WatermarkingError("PyMuPDF is required for this watermark method")
-        if not key or not isinstance(key, str):
+        if not key and not isinstance(key, str):
             raise ValueError("Key must be a non-empty string")
 
         data = load_pdf_bytes(pdf)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/ReplaceOrWithAnd, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 and iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/ReplaceOrWithAnd, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -236,7 +236,7 @@
             algorithm=hashes.SHA256(),
             length=32,
             salt=salt,
-            iterations=iter_override or self._PBKDF2_ITER,
+            iterations=iter_override and self._PBKDF2_ITER,
         )
         return kdf.derive(password.encode("utf-8"))
 
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000025D4AEB7890>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000025D49ED01A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:111: in add_watermark

    derived_key = self._derive_key(key, salt)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^

signed_annotation_watermark.py:241: in _derive_key

    return kdf.derive(password.encode("utf-8"))

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <cryptography.hazmat.primitives.kdf.pbkdf2.PBKDF2HMAC object at 0x0000025D4B2E4530>

key_material = b'unit-test-key'



    def derive(self, key_material: utils.Buffer) -> bytes:

        if self._used:

            raise AlreadyFinalized("PBKDF2 instances can only be used once.")

        self._used = True

    

>       return rust_openssl.kdf.derive_pbkdf2_hmac(

            key_material,

            self._algorithm,

            self._salt,

            self._iterations,

            self._length,

        )

E       TypeError: argument 'iterations': 'NoneType' object cannot be interpreted as an integer



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cryptography\hazmat\primitives\kdf\pbkdf2.py:51: TypeError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000025D4AEB7E00>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000025D49ED01A0>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1335/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:111: in add_watermark

    derived_key = self._derive_key(key, salt)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^

signed_annotation_watermark.py:241: in _derive_key

    return kdf.derive(password.encode("utf-8"))

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <cryptography.hazmat.primitives.kdf.pbkdf2.PBKDF2HMAC object at 0x0000025D4B363860>

key_material = b'unit-test-key'



    def derive(self, key_material: utils.Buffer) -> bytes:

        if self._used:

            raise AlreadyFinalized("PBKDF2 instances can only be used once.")

        self._used = True

    

>       return rust_openssl.kdf.derive_pbkdf2_hmac(

            key_material,

            self._algorithm,

            self._salt,

            self._iterations,

            self._length,

        )

E       TypeError: argument 'iterations': 'NoneType' object cannot be interpreted as an integer



C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\cryptography\hazmat\primitives\kdf\pbkdf2.py:51: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 20.94s

operator: core/ReplaceOrWithAnd, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -251,7 +251,7 @@
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
-                obj_str = doc.xref_object(xref, compressed=False) or ""
+                obj_str = doc.xref_object(xref, compressed=False) and ""
             except Exception as exc:
                 logging.getLogger(__name__).debug(
                     "Reading xref %s failed: %s", xref, exc
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/ReplaceOrWithAnd, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -258,7 +258,7 @@
                 )
                 continue
             lower = obj_str.lower()
-            if "/type /catalog" in lower or "/names" in lower:
+            if "/type /catalog" in lower and "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
             if len(b.strip()) < 8:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ReplaceOrWithAnd, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -330,7 +330,7 @@
             except Exception:
                 raise WatermarkingError("Malformed object hash entry") from None
             try:
-                obj_str = doc.xref_object(xref, compressed=False) or ""
+                obj_str = doc.xref_object(xref, compressed=False) and ""
             except Exception:
                 raise WatermarkingError(
                     "Referenced object missing (tampered)"
.......................F..................                               [100%]

================================== FAILURES ===================================

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001CF35D17E60>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001CF31E5B620>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1974/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

            wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )

>       extracted = wm_impl.read_secret(out_pdf, key=key)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_watermarking_all_methods.py:127: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:223: in read_secret

    self._verify_object_hashes(doc, payload.get("objs", []))

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001CF31E5B620>

doc = closed Document('None', <memory, doc# 23>)

entries = [{'sha256': '3b4bc584aeb83b71e5ea5395f7304e1176dfdcb35cbcd6080ea23be9cf05e7b2', 'xref': 1}, {'sha256': '20f81d356c4e94...8ef5d4418', 'xref': 7}, {'sha256': '3beab1e106528ed004d6d2f548364a9c3381cf379ebc552f8cb18f7a3ecbc5c5', 'xref': 8}, ...]



    def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:

        for e in entries:

            try:

                xref = int(e.get("xref"))

                expected = str(e.get("sha256"))

            except Exception:

                raise WatermarkingError("Malformed object hash entry") from None

            try:

                obj_str = doc.xref_object(xref, compressed=False) and ""

            except Exception:

                raise WatermarkingError(

                    "Referenced object missing (tampered)"

                ) from None

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            actual = self._sha256(b)

            if actual != expected:

>               raise WatermarkingError(

                    f"PDF appears tampered: object hash mismatch (xref {xref})"

                )

E               watermarking_method.WatermarkingError: PDF appears tampered: object hash mismatch (xref 1)



signed_annotation_watermark.py:344: WatermarkingError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

1 failed, 41 passed, 23 warnings in 21.12s

operator: core/ReplaceOrWithAnd, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -336,7 +336,7 @@
                     "Referenced object missing (tampered)"
                 ) from None
             lower = obj_str.lower()
-            if "/type /catalog" in lower or "/names" in lower:
+            if "/type /catalog" in lower and "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.63s

operator: core/ReplaceBreakWithContinue, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -249,7 +249,7 @@
             return out
         for xref in range(1, xref_len):
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
-                break
+                continue
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
             except Exception as exc:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.06s

operator: core/ReplaceContinueWithBreak, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -256,7 +256,7 @@
                 logging.getLogger(__name__).debug(
                     "Reading xref %s failed: %s", xref, exc
                 )
-                continue
+                break
             lower = obj_str.lower()
             if "/type /catalog" in lower or "/names" in lower:
                 continue
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ReplaceContinueWithBreak, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -259,7 +259,7 @@
                 continue
             lower = obj_str.lower()
             if "/type /catalog" in lower or "/names" in lower:
-                continue
+                break
             b = obj_str.encode("latin-1", "replace")
             if len(b.strip()) < 8:
                 continue
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/ReplaceContinueWithBreak, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -262,7 +262,7 @@
                 continue
             b = obj_str.encode("latin-1", "replace")
             if len(b.strip()) < 8:
-                continue
+                break
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
         return out
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.56s

operator: core/ReplaceContinueWithBreak, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -337,7 +337,7 @@
                 ) from None
             lower = obj_str.lower()
             if "/type /catalog" in lower or "/names" in lower:
-                continue
+                break
             b = obj_str.encode("latin-1", "replace")
             actual = self._sha256(b)
             if actual != expected:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/ExceptionReplacer, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -37,7 +37,7 @@
     import pymupdf
 
     HAS_PYMUPDF = True
-except Exception:
+except CosmicRayTestingException:
     HAS_PYMUPDF = False
 
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ExceptionReplacer, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -91,7 +91,7 @@
             doc.close()
             original = load_pdf_bytes(new_doc)
             doc = pymupdf.open(stream=original, filetype="pdf")
-        except Exception as exc:  # fallback: create new doc and append original as raw?
+        except CosmicRayTestingException as exc:  # fallback: create new doc and append original as raw?
             raise WatermarkingError(f"Failed to open PDF: {exc}") from exc
         logger = logging.getLogger(__name__)
         try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.51s

operator: core/ExceptionReplacer, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -134,7 +134,7 @@
                     and self._EMBED_NAME in doc._embfile_names()
                 ):
                     doc._embfile_del(self._EMBED_NAME)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Cleanup of existing embedded file failed: %s", exc)
             try:
                 if hasattr(doc, "_embfile_add"):
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000189A3FF3140>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        original = load_pdf_bytes(pdf)

        try:

            doc = pymupdf.open(stream=original, filetype="pdf")

            new_doc = doc.write()  # normalize structure by reloading

            doc.close()

            original = load_pdf_bytes(new_doc)

            doc = pymupdf.open(stream=original, filetype="pdf")

        except Exception as exc:  # fallback: create new doc and append original as raw?

            raise WatermarkingError(f"Failed to open PDF: {exc}") from exc

        logger = logging.getLogger(__name__)

        try:

            # Some minimal test PDFs may have no page tree; enforce at least one page.

            if doc.page_count == 0:

                # Create a brand new document with a blank page instead

                logger.debug("Rebuilding minimal PDF to include a page")

                doc.close()

                doc = pymupdf.open()

                doc.new_page()

            watermark_id = str(uuid.uuid4())

            id_hint = watermark_id[:8]

            self._add_invisible_annotation(doc, f"WM:{id_hint}")

            obj_hashes = self._select_and_hash_objects(doc)

            salt = secrets.token_bytes(self._SALT_LEN)

            nonce = secrets.token_bytes(12)

            derived_key = self._derive_key(key, salt)

            plaintext = {

                "v": self._VERSION,

                "id": watermark_id,

                "secret": secret,

                "objs": [oh.__dict__ for oh in obj_hashes],

                "secret_len": len(secret),

            }

            pt_bytes = json.dumps(plaintext, separators=(",", ":")).encode("utf-8")

            ciphertext = AESGCM(derived_key).encrypt(nonce, pt_bytes, None)

            manifest = {

                "v": self._VERSION,

                "alg": "AES-256-GCM-PBKDF2",

                "iter": self._PBKDF2_ITER,

                "salt": base64.b64encode(salt).decode("ascii"),

                "nonce": base64.b64encode(nonce).decode("ascii"),

                "ct": base64.b64encode(ciphertext).decode("ascii"),

                "id_hint": id_hint,

            }

            manifest_bytes = json.dumps(manifest, separators=(",", ":")).encode("utf-8")

            try:

                if (

                    hasattr(doc, "_embfile_names")

>                   and self._EMBED_NAME in doc._embfile_names()

                                            ^^^^^^^^^^^^^^^^^^^^

                ):

E               TypeError: Document._embfile_names() missing 1 required positional argument: 'namelist'



signed_annotation_watermark.py:134: TypeError



During handling of the above exception, another exception occurred:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000189A40BB830>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000189A3FF3140>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000189A3FF3140>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        original = load_pdf_bytes(pdf)

        try:

            doc = pymupdf.open(stream=original, filetype="pdf")

            new_doc = doc.write()  # normalize structure by reloading

            doc.close()

            original = load_pdf_bytes(new_doc)

            doc = pymupdf.open(stream=original, filetype="pdf")

        except Exception as exc:  # fallback: create new doc and append original as raw?

            raise WatermarkingError(f"Failed to open PDF: {exc}") from exc

        logger = logging.getLogger(__name__)

        try:

            # Some minimal test PDFs may have no page tree; enforce at least one page.

            if doc.page_count == 0:

                # Create a brand new document with a blank page instead

                logger.debug("Rebuilding minimal PDF to include a page")

                doc.close()

                doc = pymupdf.open()

                doc.new_page()

            watermark_id = str(uuid.uuid4())

            id_hint = watermark_id[:8]

            self._add_invisible_annotation(doc, f"WM:{id_hint}")

            obj_hashes = self._select_and_hash_objects(doc)

            salt = secrets.token_bytes(self._SALT_LEN)

            nonce = secrets.token_bytes(12)

            derived_key = self._derive_key(key, salt)

            plaintext = {

                "v": self._VERSION,

                "id": watermark_id,

                "secret": secret,

                "objs": [oh.__dict__ for oh in obj_hashes],

                "secret_len": len(secret),

            }

            pt_bytes = json.dumps(plaintext, separators=(",", ":")).encode("utf-8")

            ciphertext = AESGCM(derived_key).encrypt(nonce, pt_bytes, None)

            manifest = {

                "v": self._VERSION,

                "alg": "AES-256-GCM-PBKDF2",

                "iter": self._PBKDF2_ITER,

                "salt": base64.b64encode(salt).decode("ascii"),

                "nonce": base64.b64encode(nonce).decode("ascii"),

                "ct": base64.b64encode(ciphertext).decode("ascii"),

                "id_hint": id_hint,

            }

            manifest_bytes = json.dumps(manifest, separators=(",", ":")).encode("utf-8")

            try:

                if (

                    hasattr(doc, "_embfile_names")

                    and self._EMBED_NAME in doc._embfile_names()

                ):

                    doc._embfile_del(self._EMBED_NAME)

>           except CosmicRayTestingException as exc:

                   ^^^^^^^^^^^^^^^^^^^^^^^^^

E           NameError: name 'CosmicRayTestingException' is not defined



signed_annotation_watermark.py:137: NameError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000189A3FF3140>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        original = load_pdf_bytes(pdf)

        try:

            doc = pymupdf.open(stream=original, filetype="pdf")

            new_doc = doc.write()  # normalize structure by reloading

            doc.close()

            original = load_pdf_bytes(new_doc)

            doc = pymupdf.open(stream=original, filetype="pdf")

        except Exception as exc:  # fallback: create new doc and append original as raw?

            raise WatermarkingError(f"Failed to open PDF: {exc}") from exc

        logger = logging.getLogger(__name__)

        try:

            # Some minimal test PDFs may have no page tree; enforce at least one page.

            if doc.page_count == 0:

                # Create a brand new document with a blank page instead

                logger.debug("Rebuilding minimal PDF to include a page")

                doc.close()

                doc = pymupdf.open()

                doc.new_page()

            watermark_id = str(uuid.uuid4())

            id_hint = watermark_id[:8]

            self._add_invisible_annotation(doc, f"WM:{id_hint}")

            obj_hashes = self._select_and_hash_objects(doc)

            salt = secrets.token_bytes(self._SALT_LEN)

            nonce = secrets.token_bytes(12)

            derived_key = self._derive_key(key, salt)

            plaintext = {

                "v": self._VERSION,

                "id": watermark_id,

                "secret": secret,

                "objs": [oh.__dict__ for oh in obj_hashes],

                "secret_len": len(secret),

            }

            pt_bytes = json.dumps(plaintext, separators=(",", ":")).encode("utf-8")

            ciphertext = AESGCM(derived_key).encrypt(nonce, pt_bytes, None)

            manifest = {

                "v": self._VERSION,

                "alg": "AES-256-GCM-PBKDF2",

                "iter": self._PBKDF2_ITER,

                "salt": base64.b64encode(salt).decode("ascii"),

                "nonce": base64.b64encode(nonce).decode("ascii"),

                "ct": base64.b64encode(ciphertext).decode("ascii"),

                "id_hint": id_hint,

            }

            manifest_bytes = json.dumps(manifest, separators=(",", ":")).encode("utf-8")

            try:

                if (

                    hasattr(doc, "_embfile_names")

>                   and self._EMBED_NAME in doc._embfile_names()

                                            ^^^^^^^^^^^^^^^^^^^^

                ):

E               TypeError: Document._embfile_names() missing 1 required positional argument: 'namelist'



signed_annotation_watermark.py:134: TypeError



During handling of the above exception, another exception occurred:



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x00000189A40BBDA0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000189A3FF3140>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-1506/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000189A3FF3140>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        original = load_pdf_bytes(pdf)

        try:

            doc = pymupdf.open(stream=original, filetype="pdf")

            new_doc = doc.write()  # normalize structure by reloading

            doc.close()

            original = load_pdf_bytes(new_doc)

            doc = pymupdf.open(stream=original, filetype="pdf")

        except Exception as exc:  # fallback: create new doc and append original as raw?

            raise WatermarkingError(f"Failed to open PDF: {exc}") from exc

        logger = logging.getLogger(__name__)

        try:

            # Some minimal test PDFs may have no page tree; enforce at least one page.

            if doc.page_count == 0:

                # Create a brand new document with a blank page instead

                logger.debug("Rebuilding minimal PDF to include a page")

                doc.close()

                doc = pymupdf.open()

                doc.new_page()

            watermark_id = str(uuid.uuid4())

            id_hint = watermark_id[:8]

            self._add_invisible_annotation(doc, f"WM:{id_hint}")

            obj_hashes = self._select_and_hash_objects(doc)

            salt = secrets.token_bytes(self._SALT_LEN)

            nonce = secrets.token_bytes(12)

            derived_key = self._derive_key(key, salt)

            plaintext = {

                "v": self._VERSION,

                "id": watermark_id,

                "secret": secret,

                "objs": [oh.__dict__ for oh in obj_hashes],

                "secret_len": len(secret),

            }

            pt_bytes = json.dumps(plaintext, separators=(",", ":")).encode("utf-8")

            ciphertext = AESGCM(derived_key).encrypt(nonce, pt_bytes, None)

            manifest = {

                "v": self._VERSION,

                "alg": "AES-256-GCM-PBKDF2",

                "iter": self._PBKDF2_ITER,

                "salt": base64.b64encode(salt).decode("ascii"),

                "nonce": base64.b64encode(nonce).decode("ascii"),

                "ct": base64.b64encode(ciphertext).decode("ascii"),

                "id_hint": id_hint,

            }

            manifest_bytes = json.dumps(manifest, separators=(",", ":")).encode("utf-8")

            try:

                if (

                    hasattr(doc, "_embfile_names")

                    and self._EMBED_NAME in doc._embfile_names()

                ):

                    doc._embfile_del(self._EMBED_NAME)

>           except CosmicRayTestingException as exc:

                   ^^^^^^^^^^^^^^^^^^^^^^^^^

E           NameError: name 'CosmicRayTestingException' is not defined



signed_annotation_watermark.py:137: NameError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 20.93s

operator: core/ExceptionReplacer, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -144,7 +144,7 @@
                         filename=self._EMBED_NAME,
                         desc="Tatou signed watermark manifest v1",
                     )
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 raise WatermarkingError(
                     f"Failed to attach watermark embedded file: {exc}"
                 ) from exc
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/ExceptionReplacer, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -152,7 +152,7 @@
         finally:
             try:
                 doc.close()
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logging.getLogger(__name__).debug("Closing document failed: %s", exc)
 
     def is_watermark_applicable(
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ExceptionReplacer, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -165,7 +165,7 @@
         try:
             b = load_pdf_bytes(pdf)
             doc = pymupdf.open(stream=b, filetype="pdf")
-        except Exception:
+        except CosmicRayTestingException:
             return False
         finally:
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/ExceptionReplacer, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -170,7 +170,7 @@
         finally:
             try:
                 doc.close()
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logging.getLogger(__name__).debug("Closing document failed: %s", exc)
         return True
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s

operator: core/ExceptionReplacer, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -189,7 +189,7 @@
 
             try:
                 manifest = json.loads(manifest_bytes.decode("utf-8"))
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 raise SecretNotFoundError("Malformed watermark manifest") from exc
 
             salt = base64.b64decode(manifest["salt"])
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.34s

operator: core/ExceptionReplacer, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -205,7 +205,7 @@
             aes = AESGCM(key_bytes)
             try:
                 pt = aes.decrypt(nonce, ct, None)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 raise InvalidKeyError(
                     "Failed to authenticate watermark (key?)"
                 ) from exc
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.12s

operator: core/ExceptionReplacer, occurrence: 9
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -212,7 +212,7 @@
 
             try:
                 payload = json.loads(pt.decode("utf-8"))
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 raise SecretNotFoundError("Corrupted decrypted payload") from exc
 
             # Validate structure
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.01s

operator: core/ExceptionReplacer, occurrence: 10
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -245,7 +245,7 @@
         out: list[_ObjectHash] = []
         try:
             xref_len = doc.xref_length()
-        except Exception:
+        except CosmicRayTestingException:
             return out
         for xref in range(1, xref_len):
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.14s

operator: core/ExceptionReplacer, occurrence: 11
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -252,7 +252,7 @@
                 break
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logging.getLogger(__name__).debug(
                     "Reading xref %s failed: %s", xref, exc
                 )
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.95s

operator: core/ExceptionReplacer, occurrence: 12
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -281,7 +281,7 @@
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
                 flags = 1 | 2 | 32 | 64
                 annot.set_flags(flags)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
             try:
                 # Ensure it is not auto-open
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/ExceptionReplacer, occurrence: 13
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -287,7 +287,7 @@
                 # Ensure it is not auto-open
                 if hasattr(annot, "set_open"):
                     annot.set_open(False)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
                 annot.set_opacity(0)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/ExceptionReplacer, occurrence: 14
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -291,7 +291,7 @@
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
                 annot.set_opacity(0)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Setting annotation opacity failed: %s", exc)
             try:
                 # Shrink rectangle to a tiny box
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/ExceptionReplacer, occurrence: 15
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -298,7 +298,7 @@
                 r = annot.rect
                 tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
             try:
                 annot.update()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.05s

operator: core/ExceptionReplacer, occurrence: 16
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -302,7 +302,7 @@
                 logger.debug("Shrinking annotation rect failed: %s", exc)
             try:
                 annot.update()
-            except Exception as exc:
+            except CosmicRayTestingException as exc:
                 logger.debug("Annotation update failed: %s", exc)
         except Exception as exc:
             logger.debug("Adding invisible annotation failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.04s

operator: core/ExceptionReplacer, occurrence: 17
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -304,7 +304,7 @@
                 annot.update()
             except Exception as exc:
                 logger.debug("Annotation update failed: %s", exc)
-        except Exception as exc:
+        except CosmicRayTestingException as exc:
             logger.debug("Adding invisible annotation failed: %s", exc)
         return None
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/ExceptionReplacer, occurrence: 18
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -318,7 +318,7 @@
                     file_bytes = doc.embfile_get(self._EMBED_NAME)
                     if isinstance(file_bytes, bytes | bytearray):
                         return bytes(file_bytes)
-        except Exception as exc:
+        except CosmicRayTestingException as exc:
             logger.debug("Failed to extract embedded manifest: %s", exc)
         return None
 
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T211405666011Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T211406520245Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.44s

operator: core/ExceptionReplacer, occurrence: 19
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -327,7 +327,7 @@
             try:
                 xref = int(e.get("xref"))
                 expected = str(e.get("sha256"))
-            except Exception:
+            except CosmicRayTestingException:
                 raise WatermarkingError("Malformed object hash entry") from None
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T235536986582Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T235537858406Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 21.08s

operator: core/ExceptionReplacer, occurrence: 20
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -331,7 +331,7 @@
                 raise WatermarkingError("Malformed object hash entry") from None
             try:
                 obj_str = doc.xref_object(xref, compressed=False) or ""
-            except Exception:
+            except CosmicRayTestingException:
                 raise WatermarkingError(
                     "Referenced object missing (tampered)"
                 ) from None
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -54,7 +54,7 @@
 
     # Constants
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
-    _VERSION: Final[int] = 1
+    _VERSION: Final[int] = 2
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.32s

operator: core/NumberReplacer, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -54,7 +54,7 @@
 
     # Constants
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
-    _VERSION: Final[int] = 1
+    _VERSION: Final[int] = 0
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -55,7 +55,7 @@
     # Constants
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
     _VERSION: Final[int] = 1
-    _PBKDF2_ITER: Final[int] = 120_000
+    _PBKDF2_ITER: Final[int] = 120001
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 3
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -55,7 +55,7 @@
     # Constants
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
     _VERSION: Final[int] = 1
-    _PBKDF2_ITER: Final[int] = 120_000
+    _PBKDF2_ITER: Final[int] = 119999
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
 
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.02s

operator: core/NumberReplacer, occurrence: 4
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -56,7 +56,7 @@
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
     _VERSION: Final[int] = 1
     _PBKDF2_ITER: Final[int] = 120_000
-    _SALT_LEN: Final[int] = 16
+    _SALT_LEN: Final[int] = 17
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
 
     @staticmethod
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T181014616432Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T181015499124Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.73s

operator: core/NumberReplacer, occurrence: 5
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -56,7 +56,7 @@
     _EMBED_NAME: Final[str] = "WM-TATOU-SIGNED-v1.json"
     _VERSION: Final[int] = 1
     _PBKDF2_ITER: Final[int] = 120_000
-    _SALT_LEN: Final[int] = 16
+    _SALT_LEN: Final[int] = 15
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
 
     @staticmethod
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/NumberReplacer, occurrence: 6
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -57,7 +57,7 @@
     _VERSION: Final[int] = 1
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
-    _OBJ_SAMPLE_LIMIT: Final[int] = 12
+    _OBJ_SAMPLE_LIMIT: Final[int] = 13
 
     @staticmethod
     def get_usage() -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.91s

operator: core/NumberReplacer, occurrence: 7
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -57,7 +57,7 @@
     _VERSION: Final[int] = 1
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
-    _OBJ_SAMPLE_LIMIT: Final[int] = 12
+    _OBJ_SAMPLE_LIMIT: Final[int] = 11
 
     @staticmethod
     def get_usage() -> str:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 8
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count == 1:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.08s

operator: core/NumberReplacer, occurrence: 9
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -96,7 +96,7 @@
         logger = logging.getLogger(__name__)
         try:
             # Some minimal test PDFs may have no page tree; enforce at least one page.
-            if doc.page_count == 0:
+            if doc.page_count == -1:
                 # Create a brand new document with a blank page instead
                 logger.debug("Rebuilding minimal PDF to include a page")
                 doc.close()
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 10
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -103,7 +103,7 @@
                 doc = pymupdf.open()
                 doc.new_page()
             watermark_id = str(uuid.uuid4())
-            id_hint = watermark_id[:8]
+            id_hint = watermark_id[: 9]
             self._add_invisible_annotation(doc, f"WM:{id_hint}")
             obj_hashes = self._select_and_hash_objects(doc)
             salt = secrets.token_bytes(self._SALT_LEN)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.11s

operator: core/NumberReplacer, occurrence: 11
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -103,7 +103,7 @@
                 doc = pymupdf.open()
                 doc.new_page()
             watermark_id = str(uuid.uuid4())
-            id_hint = watermark_id[:8]
+            id_hint = watermark_id[: 7]
             self._add_invisible_annotation(doc, f"WM:{id_hint}")
             obj_hashes = self._select_and_hash_objects(doc)
             salt = secrets.token_bytes(self._SALT_LEN)
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T175236418522Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T175237313977Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

10 failed, 32 passed, 23 warnings in 20.56s

operator: core/NumberReplacer, occurrence: 12
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -107,7 +107,7 @@
             self._add_invisible_annotation(doc, f"WM:{id_hint}")
             obj_hashes = self._select_and_hash_objects(doc)
             salt = secrets.token_bytes(self._SALT_LEN)
-            nonce = secrets.token_bytes(12)
+            nonce = secrets.token_bytes( 13)
             derived_key = self._derive_key(key, salt)
             plaintext = {
                 "v": self._VERSION,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 13
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -107,7 +107,7 @@
             self._add_invisible_annotation(doc, f"WM:{id_hint}")
             obj_hashes = self._select_and_hash_objects(doc)
             salt = secrets.token_bytes(self._SALT_LEN)
-            nonce = secrets.token_bytes(12)
+            nonce = secrets.token_bytes( 11)
             derived_key = self._derive_key(key, salt)
             plaintext = {
                 "v": self._VERSION,
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/NumberReplacer, occurrence: 14
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 1 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.87s

operator: core/NumberReplacer, occurrence: 15
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= -1 or iter_count > 300_000:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.23s

operator: core/NumberReplacer, occurrence: 16
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count > 300001:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.41s

operator: core/NumberReplacer, occurrence: 17
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -198,7 +198,7 @@
             iter_count = int(manifest.get("iter", self._PBKDF2_ITER))
             # Limit to 300k iterations to prevent DoS attacks
             # triggered by excessive PBKDF2 computation
-            if iter_count <= 0 or iter_count > 300_000:
+            if iter_count <= 0 or iter_count > 299999:
                 raise WatermarkingError("Unreasonable PBKDF2 iteration count")
 
             key_bytes = self._derive_key(key, salt, iter_override=iter_count)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.68s

operator: core/NumberReplacer, occurrence: 18
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -234,7 +234,7 @@
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,
+            length= 33,
             salt=salt,
             iterations=iter_override or self._PBKDF2_ITER,
         )
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022FDE127890>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022FDDFABF80>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022FDDFABF80>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        original = load_pdf_bytes(pdf)

        try:

            doc = pymupdf.open(stream=original, filetype="pdf")

            new_doc = doc.write()  # normalize structure by reloading

            doc.close()

            original = load_pdf_bytes(new_doc)

            doc = pymupdf.open(stream=original, filetype="pdf")

        except Exception as exc:  # fallback: create new doc and append original as raw?

            raise WatermarkingError(f"Failed to open PDF: {exc}") from exc

        logger = logging.getLogger(__name__)

        try:

            # Some minimal test PDFs may have no page tree; enforce at least one page.

            if doc.page_count == 0:

                # Create a brand new document with a blank page instead

                logger.debug("Rebuilding minimal PDF to include a page")

                doc.close()

                doc = pymupdf.open()

                doc.new_page()

            watermark_id = str(uuid.uuid4())

            id_hint = watermark_id[:8]

            self._add_invisible_annotation(doc, f"WM:{id_hint}")

            obj_hashes = self._select_and_hash_objects(doc)

            salt = secrets.token_bytes(self._SALT_LEN)

            nonce = secrets.token_bytes(12)

            derived_key = self._derive_key(key, salt)

            plaintext = {

                "v": self._VERSION,

                "id": watermark_id,

                "secret": secret,

                "objs": [oh.__dict__ for oh in obj_hashes],

                "secret_len": len(secret),

            }

            pt_bytes = json.dumps(plaintext, separators=(",", ":")).encode("utf-8")

>           ciphertext = AESGCM(derived_key).encrypt(nonce, pt_bytes, None)

                         ^^^^^^^^^^^^^^^^^^^

E           ValueError: AESGCM key must be 128, 192, or 256 bits.



signed_annotation_watermark.py:120: ValueError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000022FDE127E00>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022FDDFABF80>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2150/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000022FDDFABF80>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        original = load_pdf_bytes(pdf)

        try:

            doc = pymupdf.open(stream=original, filetype="pdf")

            new_doc = doc.write()  # normalize structure by reloading

            doc.close()

            original = load_pdf_bytes(new_doc)

            doc = pymupdf.open(stream=original, filetype="pdf")

        except Exception as exc:  # fallback: create new doc and append original as raw?

            raise WatermarkingError(f"Failed to open PDF: {exc}") from exc

        logger = logging.getLogger(__name__)

        try:

            # Some minimal test PDFs may have no page tree; enforce at least one page.

            if doc.page_count == 0:

                # Create a brand new document with a blank page instead

                logger.debug("Rebuilding minimal PDF to include a page")

                doc.close()

                doc = pymupdf.open()

                doc.new_page()

            watermark_id = str(uuid.uuid4())

            id_hint = watermark_id[:8]

            self._add_invisible_annotation(doc, f"WM:{id_hint}")

            obj_hashes = self._select_and_hash_objects(doc)

            salt = secrets.token_bytes(self._SALT_LEN)

            nonce = secrets.token_bytes(12)

            derived_key = self._derive_key(key, salt)

            plaintext = {

                "v": self._VERSION,

                "id": watermark_id,

                "secret": secret,

                "objs": [oh.__dict__ for oh in obj_hashes],

                "secret_len": len(secret),

            }

            pt_bytes = json.dumps(plaintext, separators=(",", ":")).encode("utf-8")

>           ciphertext = AESGCM(derived_key).encrypt(nonce, pt_bytes, None)

                         ^^^^^^^^^^^^^^^^^^^

E           ValueError: AESGCM key must be 128, 192, or 256 bits.



signed_annotation_watermark.py:120: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 21.15s

operator: core/NumberReplacer, occurrence: 19
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -234,7 +234,7 @@
     ) -> bytes:
         kdf = PBKDF2HMAC(
             algorithm=hashes.SHA256(),
-            length=32,
+            length= 31,
             salt=salt,
             iterations=iter_override or self._PBKDF2_ITER,
         )
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026509687890>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000265085AD340>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000265085AD340>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        original = load_pdf_bytes(pdf)

        try:

            doc = pymupdf.open(stream=original, filetype="pdf")

            new_doc = doc.write()  # normalize structure by reloading

            doc.close()

            original = load_pdf_bytes(new_doc)

            doc = pymupdf.open(stream=original, filetype="pdf")

        except Exception as exc:  # fallback: create new doc and append original as raw?

            raise WatermarkingError(f"Failed to open PDF: {exc}") from exc

        logger = logging.getLogger(__name__)

        try:

            # Some minimal test PDFs may have no page tree; enforce at least one page.

            if doc.page_count == 0:

                # Create a brand new document with a blank page instead

                logger.debug("Rebuilding minimal PDF to include a page")

                doc.close()

                doc = pymupdf.open()

                doc.new_page()

            watermark_id = str(uuid.uuid4())

            id_hint = watermark_id[:8]

            self._add_invisible_annotation(doc, f"WM:{id_hint}")

            obj_hashes = self._select_and_hash_objects(doc)

            salt = secrets.token_bytes(self._SALT_LEN)

            nonce = secrets.token_bytes(12)

            derived_key = self._derive_key(key, salt)

            plaintext = {

                "v": self._VERSION,

                "id": watermark_id,

                "secret": secret,

                "objs": [oh.__dict__ for oh in obj_hashes],

                "secret_len": len(secret),

            }

            pt_bytes = json.dumps(plaintext, separators=(",", ":")).encode("utf-8")

>           ciphertext = AESGCM(derived_key).encrypt(nonce, pt_bytes, None)

                         ^^^^^^^^^^^^^^^^^^^

E           ValueError: AESGCM key must be 128, 192, or 256 bits.



signed_annotation_watermark.py:120: ValueError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000026509687E00>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000265085AD340>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-128/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x00000265085AD340>

pdf = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', key = 'unit-test-key'

intended_for = 'unit-test-recipient', position = None



    def add_watermark(

        self,

        pdf: PdfSource,

        secret: str,

        key: str,

        intended_for: str | None = None,

        position: str | None = None,

    ) -> bytes:

        if not HAS_PYMUPDF:

            raise WatermarkingError("PyMuPDF is required for this watermark method")

        if not secret or not isinstance(secret, str):

            raise ValueError("Secret must be a non-empty string")

        if not key or not isinstance(key, str):

            raise ValueError("Key must be a non-empty string")

    

        original = load_pdf_bytes(pdf)

        try:

            doc = pymupdf.open(stream=original, filetype="pdf")

            new_doc = doc.write()  # normalize structure by reloading

            doc.close()

            original = load_pdf_bytes(new_doc)

            doc = pymupdf.open(stream=original, filetype="pdf")

        except Exception as exc:  # fallback: create new doc and append original as raw?

            raise WatermarkingError(f"Failed to open PDF: {exc}") from exc

        logger = logging.getLogger(__name__)

        try:

            # Some minimal test PDFs may have no page tree; enforce at least one page.

            if doc.page_count == 0:

                # Create a brand new document with a blank page instead

                logger.debug("Rebuilding minimal PDF to include a page")

                doc.close()

                doc = pymupdf.open()

                doc.new_page()

            watermark_id = str(uuid.uuid4())

            id_hint = watermark_id[:8]

            self._add_invisible_annotation(doc, f"WM:{id_hint}")

            obj_hashes = self._select_and_hash_objects(doc)

            salt = secrets.token_bytes(self._SALT_LEN)

            nonce = secrets.token_bytes(12)

            derived_key = self._derive_key(key, salt)

            plaintext = {

                "v": self._VERSION,

                "id": watermark_id,

                "secret": secret,

                "objs": [oh.__dict__ for oh in obj_hashes],

                "secret_len": len(secret),

            }

            pt_bytes = json.dumps(plaintext, separators=(",", ":")).encode("utf-8")

>           ciphertext = AESGCM(derived_key).encrypt(nonce, pt_bytes, None)

                         ^^^^^^^^^^^^^^^^^^^

E           ValueError: AESGCM key must be 128, 192, or 256 bits.



signed_annotation_watermark.py:120: ValueError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 21.12s

operator: core/NumberReplacer, occurrence: 20
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -247,7 +247,7 @@
             xref_len = doc.xref_length()
         except Exception:
             return out
-        for xref in range(1, xref_len):
+        for xref in range( 2, xref_len):
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.79s

operator: core/NumberReplacer, occurrence: 21
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -247,7 +247,7 @@
             xref_len = doc.xref_length()
         except Exception:
             return out
-        for xref in range(1, xref_len):
+        for xref in range( 0, xref_len):
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.20s

operator: core/NumberReplacer, occurrence: 22
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) < 9:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 23
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -261,7 +261,7 @@
             if "/type /catalog" in lower or "/names" in lower:
                 continue
             b = obj_str.encode("latin-1", "replace")
-            if len(b.strip()) < 8:
+            if len(b.strip()) < 7:
                 continue
             sha256 = self._sha256(b)
             out.append(_ObjectHash(xref=xref, sha256=sha256))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.15s

operator: core/NumberReplacer, occurrence: 24
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count == 1:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.84s

operator: core/NumberReplacer, occurrence: 25
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -270,7 +270,7 @@
     def _add_invisible_annotation(self, doc: pymupdf.Document, text: str) -> None:
         logger = logging.getLogger(__name__)
         try:
-            if doc.page_count == 0:
+            if doc.page_count == -1:
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.83s

operator: core/NumberReplacer, occurrence: 26
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -272,7 +272,7 @@
         try:
             if doc.page_count == 0:
                 doc.new_page()
-            page = doc.load_page(0)
+            page = doc.load_page( 1)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
             tl_point = (margin, page.rect.height - margin)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.80s

operator: core/NumberReplacer, occurrence: 27
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -272,7 +272,7 @@
         try:
             if doc.page_count == 0:
                 doc.new_page()
-            page = doc.load_page(0)
+            page = doc.load_page( -1)
             # Place near top-left (PDF origin is bottom-left)
             margin = 2
             tl_point = (margin, page.rect.height - margin)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.92s

operator: core/NumberReplacer, occurrence: 28
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -274,7 +274,7 @@
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
-            margin = 2
+            margin = 3
             tl_point = (margin, page.rect.height - margin)
             annot = page.add_text_annot(tl_point, text)
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 29
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -274,7 +274,7 @@
                 doc.new_page()
             page = doc.load_page(0)
             # Place near top-left (PDF origin is bottom-left)
-            margin = 2
+            margin = 1
             tl_point = (margin, page.rect.height - margin)
             annot = page.add_text_annot(tl_point, text)
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.74s

operator: core/NumberReplacer, occurrence: 30
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 2 | 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/NumberReplacer, occurrence: 31
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 0 | 2 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.82s

operator: core/NumberReplacer, occurrence: 32
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 3 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.77s

operator: core/NumberReplacer, occurrence: 33
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 1 | 32 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
.FFF.F.F.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 401 == 200

E        +  where 401 = <WrapperTestResponse 32 bytes [401 UNAUTHORIZED]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:272 Failed login attempt for email: user@email.se

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T192725032683Z__input.pdf user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:486 Document not found or access denied for id=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:610 Document not found or access denied for id=1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 404 == 201

E        +  where 404 = <WrapperTestResponse 31 bytes [404 NOT FOUND]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:972 Document not found or access denied for watermarking id=1

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T192725926381Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 404 == 200

E        +  where 404 = <WrapperTestResponse streamed [404 NOT FOUND]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

WARNING  server:server.py:850 Document not found or access denied for deletion id=2

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 401 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_versions_route - assert 404 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 404 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 404 == 200

8 failed, 34 passed, 23 warnings in 20.35s

operator: core/NumberReplacer, occurrence: 34
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 33 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.66s

operator: core/NumberReplacer, occurrence: 35
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 31 | 64
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.97s

operator: core/NumberReplacer, occurrence: 36
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 | 65
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.94s

operator: core/NumberReplacer, occurrence: 37
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -279,7 +279,7 @@
             annot = page.add_text_annot(tl_point, text)
             try:
                 # Flags: Invisible(1) | Hidden(2) | NoView(32) | ReadOnly(64)
-                flags = 1 | 2 | 32 | 64
+                flags = 1 | 2 | 32 | 63
                 annot.set_flags(flags)
             except Exception as exc:
                 logger.debug("Setting annotation flags failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 38
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -290,7 +290,7 @@
             except Exception as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
-                annot.set_opacity(0)
+                annot.set_opacity( 1)
             except Exception as exc:
                 logger.debug("Setting annotation opacity failed: %s", exc)
             try:
.FFFFFFF.FFF..............................                               [100%]

================================== FAILURES ===================================

___________________________ test_create_user_route ____________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_user_route(client):

        """Test user creation endpoint."""

        parameters = {

            "login": "username",

            "password": "password",

            "email": "user@email.se",

        }  # pragma: allowlist secret

        resp = client.post("/api/create-user", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 201  # Endpoint should exist

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:76: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:236 Database error in create_user: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

______________________________ test_login_route _______________________________



client = <FlaskClient <Flask 'server'>>



    def test_login_route(client):

        """Test login endpoint."""

        parameters = {

            "email": "user@email.se",

            "password": "password",

        }  # pragma: allowlist secret

        resp = client.post("/api/login", json=parameters)

        resp_data = resp.get_json()

    

        # Note: This will likely fail due to database connectivity in tests

        # but we can test that the endpoint exists and handles the request

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 30 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:129: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:280 Database error in login: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

_________________________ test_upload_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_upload_document_route(client):

        """Test document upload endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #open dummy file

        with open(file_path, "rb") as f:

            parameters = {

                "file": (f, "input.pdf"),

                "name": "My File"

            }

    

            resp = client.post("/api/upload-document", data=parameters, content_type='multipart/form-data')

            resp_data = resp.get_json()

    

            #tests when fully functional

            #basic tests

>           assert resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:167: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T180909435665Z__input.pdf user=1

__________________________ test_list_documents_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_documents_route(client):

        """Test document list endpoint."""

        resp = client.get("/api/list-documents")

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 55 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:213: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:432 Database error in list_documents for user=1

__________________________ test_list_versions_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_versions_route(client):

        """Test list versions endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/list-versions", query_string = parameters)

        #resp = client.get("/api/list-versions/1") #for test without parameters

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:235: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:504 Database error in list_versions: 1,1

________________________ test_list_all_versions_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_list_all_versions_route(client):

        """Test list all versions endpoint."""

        #call without parameters

        resp = client.get("/api/list-all-versions") #Fix list all versions on API.md!

        resp_data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse 54 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:270: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:551 Database error in list_all_versions for user=1

___________________________ test_get_document_route ___________________________



client = <FlaskClient <Flask 'server'>>



    def test_get_document_route(client):

        """Test get document endpoint."""

        parameters = {"documentid":1}

        resp = client.get("/api/get-document", query_string=parameters)

        #resp = client.get("/api/get-document/1") #for test without parameters

    

        # Check Content-Type

        is_pdf = resp.headers.get('Content-Type') == 'application/pdf'

        # Check Content-Disposition for 'inline'

        content_disposition = resp.headers.get('Content-Disposition', '')

        is_inline = 'inline' in content_disposition.lower()

        #Oracle

>       assert is_pdf

E       assert False



..\test\test_api.py:297: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:600 Database error in get_document: 1,1

_________________________ test_create_watermark_route _________________________



client = <FlaskClient <Flask 'server'>>



    def test_create_watermark_route(client):

        """Test create watermark endpoint."""

        parameters = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                        "secret": "secret", "intended_for":"Mickey Mouse", "id": 1}

        parameters_no_id = {"method": "robust-xmp", "position": "metadata-only", "key": "key",

                            "secret": "secret", "intended_for":"Mickey Mouse"}

        resp = client.post("/api/create-watermark", json=parameters)

        #resp = client.post("/apicreate-watermark/1", json=parameters_no_id)

        data = resp.get_json()

    

        #basic tests

>       assert resp.status_code == 201

E       assert 503 == 201

E        +  where 503 = <WrapperTestResponse 27 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:337: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:968 Database error fetching document (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

__________________________ test_read_watermark_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_read_watermark_route(client):

        """Test read watermark endpoint."""

        file_path = script_dir / "storage" / "files" / "username" / "input.pdf"

        #Upload watermarked file to the app

        with open(file_path, "rb") as f:

            data = {

                "file": (f, "watermarked.pdf"),

                "name": "Water File"

            }

            upload_resp = client.post("/api/upload-document", data=data, content_type='multipart/form-data')

            upload_resp_data = upload_resp.get_json()

>           assert upload_resp.status_code == 201

E           assert 503 == 201

E            +  where 503 = <WrapperTestResponse 36 bytes [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:404: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:393 Database error inserting document path=C:\Users\franc\Documents\GitHub\softsec-tatou\server\src\storage\files\username\20251017T180910341307Z__watermarked.pdf user=1

_________________________ test_delete_document_route __________________________



client = <FlaskClient <Flask 'server'>>



    def test_delete_document_route(client):

        document_id = {"id": 2}

        resp = client.delete("/api/delete-document", json=document_id)

        #resp = client.delete("/api/delete-document/2")

    

>       assert resp.status_code == 200

E       assert 503 == 200

E        +  where 503 = <WrapperTestResponse streamed [503 SERVICE UNAVAILABLE]>.status_code



..\test\test_api.py:457: AssertionError

------------------------------ Captured log call ------------------------------

ERROR    server:server.py:844 DB delete error for doc id=2: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

(Background on this error at: https://sqlalche.me/e/20/e3q8)

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_create_user_route - assert 503 == 201

FAILED ..\test\test_api.py::test_login_route - assert 503 == 200

FAILED ..\test\test_api.py::test_upload_document_route - assert 503 == 201

FAILED ..\test\test_api.py::test_list_documents_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_list_all_versions_route - assert 503 == 200

FAILED ..\test\test_api.py::test_get_document_route - assert False

FAILED ..\test\test_api.py::test_create_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_read_watermark_route - assert 503 == 201

FAILED ..\test\test_api.py::test_delete_document_route - assert 503 == 200

10 failed, 32 passed, 23 warnings in 20.93s

operator: core/NumberReplacer, occurrence: 39
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -290,7 +290,7 @@
             except Exception as exc:
                 logger.debug("Setting annotation open state failed: %s", exc)
             try:
-                annot.set_opacity(0)
+                annot.set_opacity( -1)
             except Exception as exc:
                 logger.debug("Setting annotation opacity failed: %s", exc)
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.86s

operator: core/NumberReplacer, occurrence: 40
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 3, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.99s

operator: core/NumberReplacer, occurrence: 41
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 1, r.x0 + 2, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.41s

operator: core/NumberReplacer, occurrence: 42
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 3, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.07s

operator: core/NumberReplacer, occurrence: 43
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -296,7 +296,7 @@
             try:
                 # Shrink rectangle to a tiny box
                 r = annot.rect
-                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 2, r.y1)
+                tiny = pymupdf.Rect(r.x0, r.y1 - 2, r.x0 + 1, r.y1)
                 annot.set_rect(tiny)
             except Exception as exc:
                 logger.debug("Shrinking annotation rect failed: %s", exc)
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 21.00s

operator: core/RemoveDecorator, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -39,9 +39,6 @@
     HAS_PYMUPDF = True
 except Exception:
     HAS_PYMUPDF = False
-
-
-@dataclass
 class _ObjectHash:
     xref: int
     sha256: str
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019F620139E0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000019F61F4F320>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:105: in add_watermark

    obj_hashes = self._select_and_hash_objects(doc)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000019F61F4F320>

doc = closed Document('None', <memory, doc# 15>)



    def _select_and_hash_objects(self, doc: pymupdf.Document) -> list[_ObjectHash]:

        """Return hashes of a subset of objects after annotation insertion."""

        out: list[_ObjectHash] = []

        try:

            xref_len = doc.xref_length()

        except Exception:

            return out

        for xref in range(1, xref_len):

            if len(out) >= self._OBJ_SAMPLE_LIMIT:

                break

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception as exc:

                logging.getLogger(__name__).debug(

                    "Reading xref %s failed: %s", xref, exc

                )

                continue

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            if len(b.strip()) < 8:

                continue

            sha256 = self._sha256(b)

>           out.append(_ObjectHash(xref=xref, sha256=sha256))

                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: _ObjectHash() takes no arguments



signed_annotation_watermark.py:264: TypeError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x0000019F62013F50>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000019F61F4F320>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2421/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:105: in add_watermark

    obj_hashes = self._select_and_hash_objects(doc)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x0000019F61F4F320>

doc = closed Document('None', <memory, doc# 22>)



    def _select_and_hash_objects(self, doc: pymupdf.Document) -> list[_ObjectHash]:

        """Return hashes of a subset of objects after annotation insertion."""

        out: list[_ObjectHash] = []

        try:

            xref_len = doc.xref_length()

        except Exception:

            return out

        for xref in range(1, xref_len):

            if len(out) >= self._OBJ_SAMPLE_LIMIT:

                break

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception as exc:

                logging.getLogger(__name__).debug(

                    "Reading xref %s failed: %s", xref, exc

                )

                continue

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            if len(b.strip()) < 8:

                continue

            sha256 = self._sha256(b)

>           out.append(_ObjectHash(xref=xref, sha256=sha256))

                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

E           TypeError: _ObjectHash() takes no arguments



signed_annotation_watermark.py:264: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 21.41s

operator: core/RemoveDecorator, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -58,8 +58,6 @@
     _PBKDF2_ITER: Final[int] = 120_000
     _SALT_LEN: Final[int] = 16
     _OBJ_SAMPLE_LIMIT: Final[int] = 12
-
-    @staticmethod
     def get_usage() -> str:
         return (
             "TamperÔÇæresistant watermark using encrypted embedded file"
........F................................F                               [100%]

================================== FAILURES ===================================

_____________________ test_get_watermarking_methods_route _____________________



client = <FlaskClient <Flask 'server'>>



    def test_get_watermarking_methods_route(client):

        """Test get watermarking methods endpoint."""

>       resp = client.get("/api/get-watermarking-methods")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



..\test\test_api.py:312: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1162: in get

    return self.open(*args, **kw)

           ^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\testing.py:235: in open

    response = super().open(

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1116: in open

    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:988: in run_wsgi_app

    rv = run_wsgi_app(self.application, environ, buffered=buffered)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\werkzeug\test.py:1264: in run_wsgi_app

    app_rv = app(environ, start_response)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1536: in __call__

    return self.wsgi_app(environ, start_response)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1514: in wsgi_app

    response = self.handle_exception(e)

               ^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:1511: in wsgi_app

    response = self.full_dispatch_request()

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:919: in full_dispatch_request

    rv = self.handle_user_exception(e)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:917: in full_dispatch_request

    rv = self.dispatch_request()

         ^^^^^^^^^^^^^^^^^^^^^^^

C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask\app.py:902: in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



    @app.get("/api/get-watermarking-methods")

    def get_watermarking_methods():

        methods = []

    

        for m in WMUtils.METHODS:

            methods.append(

>               {"name": m, "description": WMUtils.get_method(m).get_usage()}

                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

            )

E           TypeError: SignedAnnotationWatermark.get_usage() takes 0 positional arguments but 1 was given



server.py:1137: TypeError

_________ TestWatermarkingUtils.test_method_get_usage_returns_string __________



self = <test_watermarking_utilities.TestWatermarkingUtils object at 0x000001E2CDD1E360>



    def test_method_get_usage_returns_string(self):

        """Test that all methods return string from get_usage."""

        for _name, method in WMUtils.METHODS.items():

>           usage = method.get_usage()

                    ^^^^^^^^^^^^^^^^^^

E           TypeError: SignedAnnotationWatermark.get_usage() takes 0 positional arguments but 1 was given



..\test\test_watermarking_utilities.py:258: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_api.py::test_get_watermarking_methods_route - TypeError: ...

FAILED ..\test\test_watermarking_utilities.py::TestWatermarkingUtils::test_method_get_usage_returns_string

2 failed, 40 passed, 23 warnings in 20.93s

operator: core/RemoveDecorator, occurrence: 2
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -344,8 +344,6 @@
                 raise WatermarkingError(
                     f"PDF appears tampered: object hash mismatch (xref {xref})"
                 )
-
-    @staticmethod
     def _sha256(b: bytes) -> str:
         h = hashes.Hash(hashes.SHA256())
         h.update(b)
....................F..F..................                               [100%]

================================== FAILURES ===================================

___ TestAllWatermarkingMethods.test_add_watermark_and_shape[signed-annots] ____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C70F92B6E0>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001C70F863230>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'



    def test_add_watermark_and_shape(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        original = sample_pdf_path.read_bytes()

>       out_bytes = wm_impl.add_watermark(

            sample_pdf_path,

            secret=secret,

            key=key,

            intended_for=intended_for,

            position=None,

        )



..\test\test_watermarking_all_methods.py:87: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:108: in add_watermark

    obj_hashes = self._select_and_hash_objects(doc)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001C70F863230>

doc = closed Document('None', <memory, doc# 15>)



    def _select_and_hash_objects(self, doc: pymupdf.Document) -> list[_ObjectHash]:

        """Return hashes of a subset of objects after annotation insertion."""

        out: list[_ObjectHash] = []

        try:

            xref_len = doc.xref_length()

        except Exception:

            return out

        for xref in range(1, xref_len):

            if len(out) >= self._OBJ_SAMPLE_LIMIT:

                break

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception as exc:

                logging.getLogger(__name__).debug(

                    "Reading xref %s failed: %s", xref, exc

                )

                continue

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            if len(b.strip()) < 8:

                continue

>           sha256 = self._sha256(b)

                     ^^^^^^^^^^^^^^^

E           TypeError: SignedAnnotationWatermark._sha256() takes 1 positional argument but 2 were given



signed_annotation_watermark.py:266: TypeError

____ TestAllWatermarkingMethods.test_read_secret_roundtrip[signed-annots] _____



self = <test_watermarking_all_methods.TestAllWatermarkingMethods object at 0x000001C70F92BC50>

method_name = 'signed-annots'

impl = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001C70F863230>

sample_pdf_path = WindowsPath('C:/Users/franc/Documents/GitHub/softsec-tatou/server/test/storage/files/username/input.pdf')

secret = 'unit-test-secret', intended_for = 'unit-test-recipient'

key = 'unit-test-key'

tmp_path = WindowsPath('C:/Users/franc/AppData/Local/Temp/pytest-of-franc/pytest-2260/test_read_secret_roundtrip_sig0')



    def test_read_secret_roundtrip(

        self,

        method_name: str,

        impl: WatermarkingMethod,

        sample_pdf_path: Path,

        secret: str,

        intended_for: str,

        key: str,

        tmp_path: Path,

    ):

        wm_impl = _as_instance(impl)

        if not wm_impl.is_watermark_applicable(sample_pdf_path, position=None):

            pytest.skip(f"{method_name}: not applicable to the sample PDF")

        out_pdf = tmp_path / f"{method_name}_watermarked.pdf"

        out_pdf.write_bytes(

>           wm_impl.add_watermark(

                sample_pdf_path,

                secret=secret,

                key=key,

                intended_for=intended_for,

                position=None,

            )

        )



..\test\test_watermarking_all_methods.py:119: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

signed_annotation_watermark.py:108: in add_watermark

    obj_hashes = self._select_and_hash_objects(doc)

                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



self = <signed_annotation_watermark.SignedAnnotationWatermark object at 0x000001C70F863230>

doc = closed Document('None', <memory, doc# 22>)



    def _select_and_hash_objects(self, doc: pymupdf.Document) -> list[_ObjectHash]:

        """Return hashes of a subset of objects after annotation insertion."""

        out: list[_ObjectHash] = []

        try:

            xref_len = doc.xref_length()

        except Exception:

            return out

        for xref in range(1, xref_len):

            if len(out) >= self._OBJ_SAMPLE_LIMIT:

                break

            try:

                obj_str = doc.xref_object(xref, compressed=False) or ""

            except Exception as exc:

                logging.getLogger(__name__).debug(

                    "Reading xref %s failed: %s", xref, exc

                )

                continue

            lower = obj_str.lower()

            if "/type /catalog" in lower or "/names" in lower:

                continue

            b = obj_str.encode("latin-1", "replace")

            if len(b.strip()) < 8:

                continue

>           sha256 = self._sha256(b)

                     ^^^^^^^^^^^^^^^

E           TypeError: SignedAnnotationWatermark._sha256() takes 1 positional argument but 2 were given



signed_annotation_watermark.py:266: TypeError

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

=========================== short test summary info ===========================

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_add_watermark_and_shape[signed-annots]

FAILED ..\test\test_watermarking_all_methods.py::TestAllWatermarkingMethods::test_read_secret_roundtrip[signed-annots]

2 failed, 40 passed, 23 warnings in 21.08s

operator: core/ZeroIterationForLoop, occurrence: 0
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -247,7 +247,7 @@
             xref_len = doc.xref_length()
         except Exception:
             return out
-        for xref in range(1, xref_len):
+        for xref in []:
             if len(out) >= self._OBJ_SAMPLE_LIMIT:
                 break
             try:
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.93s

operator: core/ZeroIterationForLoop, occurrence: 1
--- mutation diff ---
--- asigned_annotation_watermark.py
+++ bsigned_annotation_watermark.py
@@ -323,7 +323,7 @@
         return None
 
     def _verify_object_hashes(self, doc: pymupdf.Document, entries: list[Any]) -> None:
-        for e in entries:
+        for e in []:
             try:
                 xref = int(e.get("xref"))
                 expected = str(e.get("sha256"))
..........................................                               [100%]

============================== warnings summary ===============================

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:5: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

    import imghdr



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute



<frozen importlib._bootstrap>:488

<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute



<frozen importlib._bootstrap>:488

  <frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyPDF2\__init__.py:21: DeprecationWarning: PyPDF2 is deprecated. Please move to the pypdf library instead.

    warnings.warn(



..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: 1 warning

test/test_api.py: 15 warnings

  C:\Users\franc\AppData\Local\Programs\Python\Python312\Lib\site-packages\pgpy\constants.py:193: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.

    SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES,



-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

42 passed, 23 warnings in 20.90s